JevKnowledge implements the existing, deprecated Knowledge interface for compatibility. New applications can use JevRag directly without depending on the deprecated API.
Example: filter refund policies from an existing knowledge base
YourKnowledge implementation retrieves refund policies, shipping instructions and private compensation rules for a refund query. Keep the existing backend, remove material the user cannot access, then select relevant documents from the authorized candidates.
JevKnowledge wraps an existing instance; JevKnowledgeTool exposes results as search_knowledge. You do not need to rewrite document ingestion or vector retrieval.
1. Wrap your existing Knowledge instance
existingKnowledge is your implementation. Set up client as in Client setup. Supply a BiPredicate<RuntimeContext, Document> named canRead that deterministically checks user, tenant and document permissions.
options to ENFORCE. Selector and adapter modes must agree.
Here the ACL removes private material before JEV judges visible policies and shipping instructions. The example 0.2/0.8 thresholds do not guarantee selection of any document.
2. Register the tool or retrieve directly
Register the tool in your existingtoolkit and pass that Toolkit to the Agent:
search_knowledge. Toolkit injects RuntimeContext; model arguments cannot impersonate another user. The tool returns passage IDs and text. Add final draft review to check that the answer preserves refund conditions.
Applications generating their own answers can retrieve directly. ctx is the current user and session’s runtime context:
Run the offline example
JevIntegrationExample includes a fixed Knowledge backend with the “unused and within seven days” policy. SetJEV_CP using the build instructions:
Result semantics and limits
search_knowledge receives identity from Toolkit-injected RuntimeContext rather than model parameters. It returns authorized passage IDs and text. The upstream backend still enforces tenant retrieval boundaries; JEV grants no access.
Processing order: upstream recall, ACL, independent JEV relevance checks, probability ordering and result limit. ENFORCE requests max(candidateLimit, config.limit) candidates; candidateLimit ranges from 1 to 1,024. Other config values remain intact. Upstream thresholds may affect recall; measure it separately.
OFF/SHADOW return authorized candidates in original order without expanding retrieval. SHADOW records only suggestions. ENFORCE returns clearly relevant documents; uncertain ones are not evidence. Explicit irrelevance returns an empty list, backend errors propagate, and all-uncertain input raises an inconclusive exception. Match the selector’s mode to the adapter’s.
The adapter returns original Document objects with ID, metadata, embedding and retrieval score intact. It never overwrites the vector score with a JEV probability. addDocuments delegates unchanged without memory admission or write authorization.
Call retrieve(ctx, query, config) directly. Through the standard Knowledge interface, put RuntimeContext.class in Reactor Context; missing context is rejected to avoid implicit cross-session identity reuse. Set a separate retrieval timeout: JEV’s budget excludes the upstream backend. Cancellation propagates along the reactive chain.
See the combined example.