AgentBase
AI Agent 智能体脚手架 · Agent 智能体框架 · AI Agent 项目脚手架 ·
Agent 智能体后端 · AI 智能体开发平台 ·
LLM Agent Framework · Agent Scaffold · LLM 应用脚手架 · Agentic AI Backend
Configuration-driven AI Agent backend for secondary development — a production-grade AI Agent framework / LLM agent scaffold built on deepagents, LangChain, and LangGraph. Assemble and run production-grade AI agents / intelligent agent systems from YAML configuration, without writing boilerplate. Use it as an agent application scaffolding layer, an AI agent service framework, or an intelligent agent development starter kit.
agentbase provides YAML configuration, pluggable extension registries, component factories, a 21-command CLI, and a FastAPI service layer with 145 REST/WebSocket routes. It wires together the infrastructure every AI Agent backend needs: model configuration, prompt templates, user management, API key management, session management, memory management, knowledge base with RAG, document parsing, task queues, API security, tracing, and evaluation — all with sensible defaults and every component swappable via a one-line config change.
Key Features
- Config-driven agent assembly — agents, models, storage, embeddings defined in YAML, validated by
agentbase doctor
- Pluggable registry system — 30 extension registries (tools, middleware, subagents, parsers, embeddings, search, MCP, queue, tracer, graph, storage, checkpointer, model manager, prompt manager, user manager, API key manager, usage tracking, webhook, feedback, notification, conversation, audit, experiment, redaction, secrets, scheduler, calendar, system config, RBAC, alert); swap PostgreSQL ↔ SQLite, OpenAI ↔ local embeddings by changing one line
- Full API server — FastAPI with 145 routes: agent invoke/stream/resume, WebSocket real-time chat, async task queue, document upload + KB search, audit query + export, A/B experiments, model CRUD + connectivity testing, prompt template CRUD + rendering, user CRUD + authentication, API key CRUD + revocation + verification, OAuth2 third-party login (Google/GitHub), session management + cleanup, token usage tracking + cost statistics, webhook event notification + endpoint CRUD + delivery records, user feedback collection + ratings + statistics, notification center (create/broadcast/query/mark-read), conversation history management, scheduled task dispatch (interval/cron), calendar event management, runtime system config, RBAC role/permission management, alert rules + events, rate-limit admin, Prometheus metrics, OpenAPI docs
- RAG knowledge base — 9 document formats (PDF/DOCX/HTML/XLSX/PPTX…), 3 chunking strategies, pgvector native
<=> cosine retrieval, in-memory fallback
- 48 built-in tools — file ops, skill/memory/knowledge-base CRUD, web search & fetch, HTTP request, read-only DB query, MCP client, sandboxed code execution, email sending, audio transcription, calendar events, system-config/RBAC/alert read-only queries
- 9 middleware — request_logger, retry, timeout, summary, cache, redact_output, rate_limit, model_router, audit_log
- Enterprise hardening — API key auth, JWT/RBAC, OAuth2 (Google/GitHub), CORS, rate limiting, request tracing, structured
agentbase_<domain>_<nnn> error codes, Docker deployment
- 3,831 tests, 90% coverage — full CI pipeline via GitHub Actions
Architecture
graph TD
subgraph "Entry Points (CLI / FastAPI / WebSocket)"
A[agentbase CLI<br/>21 commands] --> C[Service Layer<br/>145 REST + WS routes]
B[FastAPI App] --> C
end
subgraph "Core (config-driven, pluggable)"
C --> D[YAML Config<br/>validated by agentbase doctor]
D --> E[Extension Registries<br/>30 pluggable providers · tools · middleware · subagents · parsers<br/>embeddings · search · MCP · queue · tracer · graph · storage · checkpointer<br/>model_manager · prompt_manager · user_manager · apikey_manager · usage<br/>webhook · feedback · notification · conversation · audit · experiment<br/>redaction · secrets · scheduler · calendar · system_config<br/>rbac · alert]
E --> F[Component Factories<br/>deepagents + LangChain + LangGraph]
end
subgraph "Infrastructure Services"
F --> G[Agent Runtime & Session]
F --> H[Memory & Knowledge Base (RAG)]
F --> I[Model/Prompt/User/APIKey Manager]
F --> J[Queue & Webhook & Usage Tracking]
F --> K[Audit & Tracing & Feedback]
F --> L[Notification & Conversation & OAuth2]
F --> M[Scheduler & Calendar & SystemConfig]
F --> N[RBAC & Alert & Migration & Evaluation]
end
style D fill:#fff3cd
style E fill:#d1e7dd
style F fill:#cfe2ff
Why agentbase? Building an AI Agent backend involves repetitive infrastructure work: model configuration, memory management, knowledge base, document parsing, task queues, API security, tracing, and more. AgentBase handles all of this with sensible defaults — and every component is pluggable via a registry system. Swap databases, embedding models, queues, or tracers by changing one line of config. No rewrite required.
Defaults are local-dev
The shipped default agent profile includes write/delete tools and an empty interrupt_on map. That is the local-dev picture, not a production default. Before exposing the API:
- Use
configs/agents/readonly.yaml, or copy configs/agents/interrupt_demo.yaml and list irreversible tools under interrupt_on.
- Production compose refuses to start without
AGENTBASE_API_KEY, YAML auth.api_key, or a JWT secret (app.env: prod / production).
- Read docs/guardrails.md and SECURITY.md.
Requirements
- Python >= 3.11
- PostgreSQL 16+ with pgvector (for production, via Docker or local install)
- Or SQLite (zero-config, no install needed, dev/single-user)
Installation
# From source (development)
pip install .
# Or with uv
uv pip install .
# With optional provider extras
pip install ".[openai,anthropic,google]"
# With PostgreSQL support
pip install ".[postgres]"
# With API server support
pip install ".[api]"
# With RAG document parsing (PDF, DOCX)
pip install ".[rag]"
# With everything
pip install ".[all]"
# With development tooling
pip install ".[dev]"
Quick Start
See docs/quickstart.md for a complete end-to-end guide.
# 1. Set your model API key
export DEEPSEEK_API_KEY="your-key-here"
# 2. Validate your setup (zero-config: SQLite storage + memory queue)
agentbase doctor
# 3. Run an agent
agentbase run "Hello, what can you do?"
# 4. Start the API server
agentbase serve --reload
Optional production stack (PostgreSQL + pgvector, Redis): docker compose up -d
— compose defaults AGENTBASE_APP__ENV=prod, so set AGENTBASE_API_KEY (or a JWT secret) or the API container refuses to start (AGENTBASE_CONFIG_004). See SECURITY.md. Local clone-and-run keeps configs/default.yaml env: dev (open API allowed).
Storage DSN: docker-compose.yml and configs/default.yaml.
CLI Commands
| Command |
Description |
agentbase doctor |
Validate configuration and agent assembly |
agentbase agents |
List available agent profiles |
agentbase extensions |
List registered extensions |
agentbase extensions --verbose |
Show extension metadata |
agentbase run "message" |
Invoke an agent (single response) |
agentbase stream "message" |
Stream an agent response |
agentbase resume --thread-id ID --decision approve |
Resume an interrupted agent run |
agentbase serve --port 8000 |
Start the FastAPI server |
agentbase backup -o backup.sql |
Backup database (SQL/JSON format) |
agentbase restore backup.sql |
Restore database from backup |
agentbase worker |
Start a queue worker process |
agentbase version |
Print version information |
agentbase config validate |
Validate configuration files |
agentbase config show |
Display resolved configuration |
agentbase db init |
Initialize migration scripts directory |
agentbase db upgrade |
Upgrade database to latest schema |
agentbase db downgrade |
Downgrade database by one step |
agentbase db current |
Show current migration revision |
agentbase db heads |
Show head migration revisions |
agentbase db history |
Show migration history |
agentbase db stamp --revision REV |
Stamp database with a revision |
agentbase eval --suite suite.yaml -o report.json |
Run an agent evaluation suite (self-assessment; exit 1 on failure) |
Common Options
--root <dir> — Project root directory
--agent <name> — Agent profile to use
--thread-id <id> — Thread ID for session continuity
API Server
Start the server:
agentbase serve --host 0.0.0.0 --port 8000 --reload
Authentication
API key is on when either AGENTBASE_API_KEY or YAML auth.api_key is non-empty. A non-empty YAML value overrides the env var. app.env: prod / production refuses to start without that key or a JWT secret (AGENTBASE_CONFIG_004). auth.type: none does not skip checks if a key is set.
# Enable auth (env). Or set auth.api_key in YAML — that wins when non-empty.
export AGENTBASE_API_KEY="your-secret-key"
# Call API with key
curl -H "Authorization: Bearer your-secret-key" http://localhost:8000/agents
# Or use X-API-Key header
curl -H "X-API-Key: your-secret-key" http://localhost:8000/agents
# Disable auth (dev fail-open only — not prod)
export AGENTBASE_API_KEY=""
JWT mode: auth.type: jwt plus AGENTBASE_AUTH__SECRET / auth.secret. Empty secret refuses start (AGENTBASE_CONFIG_002); constructing JWTAuth with an empty secret raises ValueError.
WebSocket /ws/agents/{name} uses the same _verify_auth as HTTP (Authorization / X-API-Key, or query token mapped to Bearer). Failure closes with code 4001.
Endpoints marked Public skip auth even when a key is set: /health, /docs, /redoc, /openapi.json, /, and /auth/oauth2/*. /metrics is not public when auth is on.
Endpoints (145 total)
Click to expand full endpoint list
| Method |
Endpoint |
Description |
Auth |