Observed since 20 Oct, 21:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
agent-brain-rag
Agent Brain RAG - Intelligent document indexing and semantic search server that gives AI agents long-term memory
Agent Brain (formerly doc-serve) is an intelligent document indexing and semantic search system designed to give AI agents long-term memory.
AI agents need persistent memory to be truly useful. Agent Brain provides the retrieval infrastructure that enables context-aware, knowledge-grounded AI interactions.
pip install agent-brain-rag
Set environment variables:
export OPENAI_API_KEY=your-key
export ANTHROPIC_API_KEY=your-key
Start the server:
agent-brain-serve
The server will start at http://127.0.0.1:8000.
Note: The legacy command
doc-serveis still available but deprecated. Please useagent-brain-servefor new installations.
Agent Brain provides multiple search strategies to match your retrieval needs:
| Search Type | Description | Best For |
|---|---|---|
| Semantic Search | Natural language queries using OpenAI embeddings (text-embedding-3-large) | Conceptual questions, finding related content |
| Keyword Search (BM25) | Traditional keyword matching with TF-IDF ranking | Exact matches, technical terms, code identifiers |
| Hybrid Search | Combines vector + BM25 for best of both approaches | General-purpose queries, balanced recall/precision |
| GraphRAG | Knowledge graph-based retrieval for relationship-aware queries | Understanding connections, multi-hop reasoning |
text-embedding-3-large for high-quality embeddingsAgent Brain supports optional GraphRAG (Graph-based Retrieval-Augmented Generation) for enhanced relationship-aware queries.
Set the environment variable to enable graph indexing:
export ENABLE_GRAPH_INDEX=true
| Variable | Default | Description |
|---|---|---|
ENABLE_GRAPH_INDEX | false | Enable/disable GraphRAG features |
GRAPH_STORE_TYPE | simple | Graph backend: simple (JSON) or kuzu (embedded DB) |
GRAPH_MAX_TRIPLETS_PER_CHUNK | 10 | Maximum entities to extract per document chunk |
GRAPH_USE_CODE_METADATA | true | Extract relationships from code AST metadata |
GRAPH_USE_LLM_EXTRACTION | true | Use LLM for entity extraction from documents |
GRAPH_TRAVERSAL_DEPTH | 2 | Default traversal depth for graph queries |
With GraphRAG enabled, you have access to additional query modes:
graph: Query using only the knowledge graph (entity relationships)multi: Combines vector search, BM25, and graph results using RRF fusion# CLI
agent-brain query "authentication service" --mode graph
# API
curl -X POST http://localhost:8000/query \
-H "Content-Type: application/json" \
-d '{"query": "authentication service", "mode": "graph", "top_k": 10}'
# CLI
agent-brain query "user login flow" --mode multi
# API
curl -X POST http://localhost:8000/query \
-H "Content-Type: application/json" \
-d '{"query": "user login flow", "mode": "multi", "top_k": 5}'
To rebuild only the graph index without re-indexing documents:
curl -X POST "http://localhost:8000/index?rebuild_graph=true" \
-H "Content-Type: application/json" \
-d '{"folder_path": "."}'
For enhanced GraphRAG features, install optional dependency groups:
# For Kuzu graph store (production workloads)
poetry install --with graphrag-kuzu
# For enhanced entity extraction
poetry install --with graphrag
Agent Brain supports optional two-stage retrieval with reranking for improved search precision. When enabled, the system:
Set the following environment variables:
# Enable two-stage reranking (default: false)
ENABLE_RERANKING=true
# Choose provider (default: sentence-transformers)
RERANKER_PROVIDER=sentence-transformers # or "ollama"
# Choose model (default: cross-encoder/ms-marco-MiniLM-L-6-v2)
RERANKER_MODEL=cross-encoder/ms-marco-MiniLM-L-6-v2
# Stage 1 retrieval multiplier (default: 10)
RERANKER_TOP_K_MULTIPLIER=10
# Maximum candidates for Stage 1 (default: 100)
RERANKER_MAX_CANDIDATES=100
# Batch size for reranking inference (default: 32)
RERANKER_BATCH_SIZE=32
| Provider | Model | Latency | Description |
|---|---|---|---|
| sentence-transformers | cross-encoder/ms-marco-MiniLM-L-6-v2 | ~50ms | Recommended. Fast, accurate cross-encoder. |
| sentence-transformers | cross-encoder/ms-marco-MiniLM-L-12-v2 | ~100ms | Slower but more accurate. |
| ollama | llama3.2:1b | ~500ms | Fully local, no HuggingFace download. |
You can also configure reranking in config.yaml:
reranker:
provider: sentence-transformers
model: cross-encoder/ms-marco-MiniLM-L-6-v2
params:
batch_size: 32
If the reranker fails (model unavailable, timeout, etc.), the system automatically falls back to Stage 1 results. This ensures queries never fail due to reranking issues.
When reranking is enabled, query results include additional fields:
rerank_score: The cross-encoder relevance scoreoriginal_rank: The position before reranking (1-indexed)Example response:
{
"results": [
{
"text": "Document content...",
"source": "docs/guide.md",
"score": 0.95,
"rerank_score": 0.95,
"original_rank": 5,
"chunk_id": "chunk_abc123"
}
]
}
cd agent-brain-server
poetry install
Copy the environment template and configure:
cp ../.env.example .env
# Edit .env with your API keys
Required environment variables:
OPENAI_API_KEY: Your OpenAI API key for embeddingsANTHROPIC_API_KEY: Your Anthropic API key for summarization# Development mode
poetry run uvicorn agent_brain_server.api.main:app --reload
# Or use the entry point
poetry run agent-brain-serve
Once running, visit:
GET /health - Server health statusGET /health/status - Detailed indexing statusPOST /index - Start indexing documents from a folderPOST /index/add - Add documents to existing indexDELETE /index - Reset the indexPOST /query - Semantic search queryGET /query/count - Get indexed document countcurl -X POST http://localhost:8000/index \
-H "Content-Type: application/json" \
-d '{"folder_path": "/path/to/docs"}'
curl -X POST http://localhost:8000/query \
-H "Content-Type: application/json" \
-d '{"query": "How do I configure authentication?", "top_k": 5}'
agent_brain_server/
├── api/
│ ├── main.py # FastAPI application
│ └── routers/ # Endpoint handlers
├── config/
│ └── settings.py # Configuration management
├── models/ # Pydantic request/response models
├── indexing/
│ ├── document_loader.py # Document loading
│ ├── chunking.py # Text chunking
│ └── embedding.py # Embedding generation
├── services/
│ ├── indexing_service.py # Indexing orchestration
│ └── query_service.py # Query execution
└── storage/
└── vector_store.py # Chroma vector store
poetry run pytest
poetry run black agent_brain_server/
poetry run ruff check agent_brain_server/
poetry run mypy agent_brain_server/
MIT
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
anthropicEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | anthropic<0.41.0,>=0.40.0 | runtime |
asyncpgEnvironment{
"extras": "",
"marker": "extra == \"postgres\"",
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | asyncpg<0.30.0,>=0.29.0; extra == "postgres" | runtime |
cachetoolsEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | cachetools>=5.3 | runtime |
chromadbEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | chromadb<0.6.0,>=0.5.0 | runtime |
clickEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | click<9.0.0,>=8.1.0 | runtime |
cohereEnvironment{
"extras": "",
"marker": "extra == \"cohere\"",
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | cohere<6.0,>=5.21.0; extra == "cohere" | runtime |
fastapiEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | fastapi<0.116.0,>=0.115.0 | runtime |
google-cloud-secret-managerEnvironment{
"extras": "",
"marker": "extra == \"gcp\"",
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | google-cloud-secret-manager<3.0.0,>=2.21.0; extra == "gcp" | runtime |
google-genaiEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | google-genai<2.0.0,>=1.0.0 | runtime |
langextractEnvironment{
"extras": "",
"marker": "extra == \"graphrag\" or extra == \"graphrag-all\"",
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | langextract<2.0.0,>=1.0.0; extra == "graphrag" or extra == "graphrag-all" | runtime |
llama-index-coreEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | llama-index-core<0.15.0,>=0.14.0 | runtime |
llama-index-embeddings-openaiEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | llama-index-embeddings-openai<0.6.0,>=0.5.0 | runtime |
llama-index-graph-stores-kuzuEnvironment{
"extras": "",
"marker": "extra == \"graphrag-kuzu\" or extra == \"graphrag-all\"",
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | llama-index-graph-stores-kuzu<0.10.0,>=0.9.0; extra == "graphrag-kuzu" or extra == "graphrag-all" | runtime |
llama-index-llms-openaiEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | llama-index-llms-openai<0.7.0,>=0.6.12 | runtime |
llama-index-readers-fileEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | llama-index-readers-file<0.6.0,>=0.5.0 | runtime |
llama-index-retrievers-bm25Environment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | llama-index-retrievers-bm25<0.7.0,>=0.6.0 | runtime |
openaiEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | openai<2.0.0,>=1.57.0 | runtime |
pathspecEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | pathspec<0.13.0,>=0.12.0 | runtime |
pydanticEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | pydantic<3.0.0,>=2.10.0 | runtime |
pydantic-settingsEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | pydantic-settings<3.0.0,>=2.6.0 | runtime |
python-dotenvEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | python-dotenv<2.0.0,>=1.0.0 | runtime |
pyyamlEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | pyyaml<7.0.0,>=6.0.0 | runtime |
rank-bm25Environment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | rank-bm25<0.3.0,>=0.2.2 | runtime |
sentence-transformersEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | sentence-transformers<4.0.0,>=3.4.0 | runtime |
sqlalchemyEnvironment{
"extras": "asyncio",
"marker": "extra == \"postgres\"",
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | sqlalchemy[asyncio]<3.0.0,>=2.0.0; extra == "postgres" | runtime |
tiktokenEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | tiktoken<0.9.0,>=0.8.0 | runtime |
tree-sitter-language-packEnvironment{
"extras": "",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | tree-sitter-language-pack<0.8.0,>=0.7.3 | runtime |
uvicornEnvironment{
"extras": "standard",
"marker": null,
"requires_python": "<4.0,>=3.10",
"evaluation": "NOT_EVALUATED"
} | uvicorn[standard]<0.33.0,>=0.32.0 | runtime |
bdist_wheel · 266.13 KB · Python py3
sdist · 218.85 KB · Python source
Shared repository data · GitHub
Observed since 20 Oct, 21:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:4904cd5fbb2a8b7be7e2825236258f73bc9ae74de344c3bfd655aeef5fc9d2e0