Knowledge Bases
Knowledge bases give agents access to your organization’s documents and data. AgentFlow provides a full document pipeline — ingestion, chunking, embedding, and hybrid retrieval — backed by PGVector with tenant isolation.Creating a knowledge base
From a URL
URL imports use form data and thewebsite_url field:
From files
File uploads create a KB with multipart form data on the base knowledge-bases route:client.knowledge_bases.create_from_url(...) and client.knowledge_bases.create_from_files(...).
Search
Knowledge base search supports multiple retrieval strategies:documents, total_results, and search_metadata.
Canonical search fields
| Field | Description |
|---|---|
query | Required search text |
limit | Maximum number of documents to return |
search_type | semantic, keyword, or hybrid |
vector_weight | Hybrid vector weight, from 0.0 to 1.0 |
keyword_weight | Hybrid keyword weight, from 0.0 to 1.0 |
metadata_filters | Structured metadata filters for narrowing results |
similarity_threshold | Minimum similarity score before a document is returned |
enable_mmr | Enable Maximal Marginal Relevance diversity filtering |
mmr_lambda | MMR balance: 1.0 favors relevance, 0.0 favors diversity |
enable_surrounding_chunks | Include neighboring chunks around each match |
neighboring_chunks_count | Number of adjacent chunks to include around each match |
enable_query_rewrite | Rewrite the query before retrieval when enabled |
enable_query_expansion | Expand the query before retrieval when enabled |
enable_hyde | Generate a hypothetical answer to improve semantic retrieval |
alpha | Hybrid search alpha value; vector_weight is the SDK-friendly alias |
rrf_k | Reciprocal-rank-fusion constant for hybrid result merging |
freshness_boost | Boost newer chunks when freshness should influence ranking |
freshness_half_life_days | Half-life window used by freshness boosting |
title_alpha | Boost chunks whose source title matches the query |
field_alphas | Per-field weighting for metadata-aware ranking |
rerank | Enable reranking when supported by the KB configuration |
conversation_id | Optional conversation context identifier for search telemetry |
filters_sql | Deprecated and rejected; use metadata_filters instead |
Search strategies
| Strategy | What it does |
|---|---|
| Semantic | Embedding-based similarity search using PGVector |
| Keyword | BM25-style keyword matching |
| Hybrid | Combines semantic and keyword retrieval with vector_weight and keyword_weight |
| MMR | Maximal Marginal Relevance — balances relevance with result diversity |
| Neighboring chunks | Adds adjacent chunks so cited text keeps nearby context |
Binding knowledge bases to agents
Knowledge bases become part of an agent’s context when bound:Configuration
Chunking
| Parameter | Default | Description |
|---|---|---|
chunk_size | 1200 | Maximum tokens per chunk |
overlap_percentage | 0.15 | Overlap between consecutive chunks (0.0–1.0) |
chunking_strategy | auto | Strategy for splitting documents |
Vector storage
AgentFlow uses PGVector for vector storage with:- Tenant-scoped collections for data isolation
- HNSW indexing for fast approximate nearest neighbor search
- Configurable embedding models

