SourceRetriever is the interface every agent and pipeline in CL SDK uses to fetch evidence at query time.
SourceRetriever Interface
searchSourceNodes is optional — implement it when your store has a structured node graph. Agents fall back to searchSourceSpans when searchSourceNodes is not available.
Retrieval Modes
- graph_only
- source_rag
- long_context
- hybrid
Uses structured relationships and exact metadata matches. No vector search. Best for queries where you know the exact section, form number, or metadata filter that contains the answer.
Memory Store Usage
MemorySourceStore is an in-process store backed by a flat array. It uses lexical search (substring and keyword matching) rather than vector embeddings. Use it for development, testing, and single-request extraction workflows.
MemorySourceStore is not persistent. All spans and chunks are lost when the process exits. For production use, implement SourceStore against your own database — see the Storage Overview for guidance.Deterministic Ordering
When you combine results from multiple retrieval passes (vector search + structured filters, or multiple document IDs), useorderSourceEvidence to produce a stable, deterministic ranking before passing evidence to an LLM.
Implementing a Custom SourceRetriever
You can plug any data source into CL SDK agents by implementingSourceRetriever. The minimum viable implementation requires only searchSourceSpans.
sourceRetriever config option:
Filters Reference
string
Match spans whose
sectionId equals this value. Useful for scoping queries to declarations, definitions, or named endorsements.string
Match spans from a specific ISO or carrier form (e.g.
"CG 00 01", "IM 7053").string
Filter by source kind:
"policy_pdf", "application_pdf", "email", "attachment", or "manual_note".string
Filter by span unit type:
"page", "section", "table", "table_row", "table_cell", or "text".metadata record is also available as a filter key. Filter matching is exact string equality.