Skip to main content
Grounds agent responses with WithRetrievers. Pick one backend per run.
BackendEntrypoint
Weaviatego run ./agent_with_retriever/weaviate
PostgreSQL + pgvectorgo run ./agent_with_retriever/pgvector
Sample KB documents are seeded by Task infra. Edit docker/weaviate/sample-documents.json or docker/pgvector/sample-documents.json and re-run up to change corpus content. Source: examples/agent_with_retriever/

Retriever modes

Set RETRIEVER_MODE in .env (default agentic):
ModeBehavior
agenticRetriever exposed as a tool; LLM decides when to search
prefetchSearch runs once before the first LLM call; context injected into system prompt
hybridPrefetch and retriever tools
Prefetch/hybrid embed your exact user message — use concrete questions aligned with the sample KB (returns, shipping, warranty, etc.).

Setup

From examples/:
task infra:status
Weaviate:
task infra:weaviate:up
go run ./agent_with_retriever/weaviate "What is the return policy?"
task infra:weaviate:down
pgvector:
task infra:pgvector:up
go run ./agent_with_retriever/pgvector "What is the return policy?"
task infra:pgvector:down

Run examples

# Agentic (default)
go run ./agent_with_retriever/weaviate "What is the return policy?"

# Prefetch — search before first LLM call
RETRIEVER_MODE=prefetch go run ./agent_with_retriever/weaviate "What are the return and shipping rules?"

# Hybrid
RETRIEVER_MODE=hybrid go run ./agent_with_retriever/pgvector "Summarize warranty coverage."
Use SHOW_TELEMETRY=true to compare prefetch vs agentic search counts.

Expected output

Our return policy allows returns within 30 days of purchase with a receipt.
Items must be in their original condition. Sale items are final sale.
The response is grounded in the sample KB documents seeded by task infra:weaviate:up / task infra:pgvector:up. With SHOW_TELEMETRY=true in agentic mode you’ll see total_retriever_searches: 1.

Learn more

Retrieval

Retriever modes and backends

Memory

Long-term memory on same infra