by jin-bo
A local‑first, private‑first, embeddable runtime for AI agents in Python, providing built‑in permissions, memory, protocol support, and audit‑replay capabilities.
Agentao delivers a governed agent runtime that runs locally in a Python host. It isolates every input, enforces permission modes, tracks context, persists memory in SQLite, and records full session replays. The design follows three pillars – constraint, connectivity, and observability – to make powerful agents trustworthy.
pip install agentao
from pathlib import Path
from agentao import Agentao
from agentao.llm import LLMClient
from agentao.transport import NullTransport
agent = Agentao(
working_directory=Path("/tmp/agent-run-1"),
llm_client=LLMClient(
api_key="sk-...",
base_url="https://api.openai.com/v1",
model="gpt-5.4",
),
transport=NullTransport(),
)
reply = agent.chat("Summarize today's logs.")
print(reply)
agent.close()
pip install 'agentao[cli]'
# create .env with required variables
printf "OPENAI_API_KEY=sk-your-key\nOPENAI_BASE_URL=https://api.openai.com/v1\nOPENAI_MODEL=gpt-5.4\n" > .env
# quick test
agentao -p "Reply with the single word: OK"
# interactive REPL
agentao
Use slash commands such as /help, /status, /model, /mode, /memory, /mcp list, etc., to control the session.
skills/, GitHub‑installable, crystallization workflow./copy command.Q: Do I need an internet connection?
A: Only if the selected LLM provider requires it. The runtime itself has no implicit network calls; you control all transport via LLMClient and Transport objects.
Q: Which LLM providers are supported?
A: Any OpenAI‑compatible provider (OpenAI, Anthropic, Gemini, DeepSeek, etc.) by setting <NAME>_API_KEY, <NAME>_BASE_URL, and <NAME>_MODEL. The provider is selected via LLM_PROVIDER or the /provider command.
Q: How is memory persisted? A: In a SQLite database under the working directory, separated into user‑level and project‑level scopes.
Q: Can I run Agentao as a server for other applications?
A: Yes, via the MCP/ACP protocols (stdio, Streamable HTTP, or SSE). The CLI’s /mcp list shows active server endpoints.
Q: What changed in the 0.5.0 upgrade?
A: Deprecated agentao.harness and agentao.session, revamped constructor signature, and moved CLI dependencies into the [cli] extra. See the migration docs for details.
___ _
/ _ \ ___ _ ___ ___ ___| |_ ___ ___
/ _ // _` / -_)| _ \/ _ \ _|/ _` / _ \
/_/ |_| \__, \___||_// \___/\__|\__,_\___/
|___/ (The Way of Agents)
"Order in Chaos, Path in Intelligence."
Agentao is a Governed Agent Runtime — a local-first, private-first, embeddable agent harness for Python hosts. Permissions, protocols, memory, plugins, and multi-session control are all first-class.
The full handbook lives in developer-guide/ (VitePress, bilingual). Production site: agentao.cn.
| Audience | Read | Site |
|---|---|---|
| Coding agents — Claude Code / Codex / … embedding Agentao into another project | docs/guides/embed-for-agents.md (distilled, copy-paste playbook) |
— |
CLI users — driving agentao in the terminal |
developer-guide/en/cli/ (12 chapters: slash commands · plan mode · memory · replay · …) |
agentao.cn/en/cli/ |
| Embedding developers — building Agentao into your app | developer-guide/en/ (Parts 1–7 + Appendix) |
agentao.cn |
| 中文 | developer-guide/zh/cli/ · developer-guide/zh/ |
agentao.cn/zh/cli/ · agentao.cn/zh/ |
Browse locally:
cd developer-guide && npx vitepress dev
For schema-level reference (every config file, every env var, every public API), the canonical doc is docs/reference/configuration.md. Everything else is in the Developer Guide.
pip install agentao
from pathlib import Path
from agentao import Agentao
from agentao.llm import LLMClient
from agentao.transport import NullTransport
agent = Agentao(
working_directory=Path("/tmp/agent-run-1"),
llm_client=LLMClient(
api_key="sk-...",
base_url="https://api.openai.com/v1",
model="gpt-5.4",
),
transport=NullTransport(),
)
reply = agent.chat("Summarize today's logs.")
print(reply)
agent.close()
This constructs an agent with no env-discovery, no implicit network, no global state — the host owns every input. For env-driven discovery (the path the CLI uses), call agentao.embedding.build_from_environment(working_directory=...) instead.
Embedding details: Developer Guide · Part 2 (Lifecycle) and Part 4 (Host Contract).
Coding agent (Claude Code, Codex, …) tasked with embedding Agentao into another project? Read
docs/guides/embed-for-agents.md— a distilled, copy-paste integration playbook with construction skeletons, import rules, and a checklist.
pip install 'agentao[cli]'
# .env in your project (all three are required):
printf "OPENAI_API_KEY=sk-your-key\nOPENAI_BASE_URL=https://api.openai.com/v1\nOPENAI_MODEL=gpt-5.4\n" > .env
# Smoke test — non-interactive
agentao -p "Reply with the single word: OK"
# Interactive REPL
agentao
Upgrading from 0.4.x? 0.5.0 removes what 0.4.x deprecated —
agentao.harness(useagentao.host),agentao.session(useagentao.embedding.sessions) and the eight callback kwargs onAgentao(...)(usetransport=, orbuild_compat_transport) — and two things that never warned:project_rootis required on the session functions, andAgentao(...)takes only its first five parameters positionally. See docs/migration/0.4.x-to-0.5.0.md.Upgrading from 0.3.x? From 0.4.0 the CLI deps moved into the
[cli]extra. Usepip install 'agentao[full]'for zero behaviour change. See docs/migration/0.3.x-to-0.4.0.md.
First commands once the REPL is up:
/help Every slash command + tools the agent has
/status Model, mode, tokens, active skills
/model Switch model on the current provider
/mode Switch permission mode (read-only · workspace-write · full-access · plan)
/plan Enter plan mode (read-only thinking with .agentao/plan.md)
/memory Inspect persistent memory
/mcp list MCP server status
/exit Leave cleanly (don't Ctrl+C)
CLI handbook: agentao.cn/en/cli/ — 12 chapters covering every slash command and the mental model behind them.
The name encodes the design: Agent (capability) + Tao (governance). Three pillars of a governed runtime:
| Pillar | What it means | How Agentao implements it |
|---|---|---|
| Constraint (约束) | Agents must not act without consent | Tool confirmation · permission modes (read-only / workspace-write / full-access / plan) · macOS sandbox-exec |
| Connectivity (连接) | Agents must reach the world beyond training | MCP (stdio / Streamable HTTP / SSE) · ACP (full-agent JSON-RPC) · plugins · hooks |
| Observability (可观测性) | Agents must show their work | Live thinking display · streaming tool output · full LLM logging · JSONL replay |
| Area | What you get | Deep dive |
|---|---|---|
| Governance | Tool confirmation, four permission modes, plan mode, macOS sandbox | CLI ch. 3 · ch. 4 |
| Context | Token tracking, LLM-summarized compaction, overflow recovery, file re-injection | CLI ch. 7 |
| Memory | SQLite-backed persistent memory with two scopes (user / project), automatic recall, jieba 中文 segmentation | CLI ch. 6 |
| Skills | Auto-discovered from skills/, GitHub-installable (agentao skill install owner/repo[:path][@ref]), plus /crystallize workflow |
CLI ch. 5 |
| Protocols | MCP (stdio / Streamable HTTP / SSE) for tools · ACP (stdio JSON-RPC) for full agents · plugin lifecycle | CLI ch. 8 |
| Sub-agents | Built-in codebase-investigator / generalist · custom .agentao/agents/<name>.md · foreground/background dashboard |
CLI ch. 11 |
| Replay & Output | JSONL session recordings under .agentao/replays/ · markdown-toggle · /copy last reply |
CLI ch. 9 |
| Embedding | Agentao(...) constructor · events() stream · active_permissions() · capability injection · ACP Pydantic schemas |
DG Part 2 · Part 4 |
# Embedding host (Python `from agentao import Agentao`) — smallest closure
pip install agentao
# CLI user (`agentao` console script) — adds rich/prompt-toolkit/readchar/pygments
pip install 'agentao[cli]'
# Zero-behaviour-change upgrade from 0.3.x — full closure
pip install 'agentao[full]'
Required Python: 3.10+. Required env: OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_MODEL — all three, or startup raises ValueError.
For Anthropic / Gemini / DeepSeek / any OpenAI-compatible provider, set <NAME>_API_KEY + <NAME>_BASE_URL + <NAME>_MODEL and pick it via LLM_PROVIDER or /provider at runtime. To talk to Anthropic's own API natively (Messages API — working prompt caching, signed thinking), add <NAME>_API_FORMAT=anthropic-messages; for OpenAI's Responses API (a reasoning model's reasoning kept across requests), <NAME>_API_FORMAT=openai-responses. It is never inferred from a URL or a name. Full list: docs/reference/configuration.md.
git clone https://github.com/jin-bo/agentao
cd agentao
uv sync
cp .env.example .env
# Run the CLI from source
uv run agentao
# or
./run.sh
# Tests
uv run python -m pytest tests/
Contributor entry points:
| What | Where |
|---|---|
| Project layout, code conventions | CLAUDE.md |
| Adding a tool / agent / skill | Developer Guide · Part 5 |
| Plugin author guide | Developer Guide · §5.7 |
| Embedding contract & ACP schemas | Developer Guide · Part 4 |
| Examples (skills · personas · integration blueprints) | examples/ |
pip install agentao and you're running. No databases, no cloud dependencies.agentao.log.Agentao = Agent + Tao (道) — the natural order that underlies all things. Three intertwined meanings:
An agent without Tao is powerful but unpredictable. Agentao is the structure that makes that power trustworthy.
Open source. Use and modify as needed.
web_fetch: PlaywrightPlease log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by modelcontextprotocol
An MCP server implementation that provides a tool for dynamic and reflective problem-solving through a structured thinking process.
by zylon-ai
Provides an open-source API layer that enables local OpenAI‑compatible models to be used for production AI applications, offering standardized message handling, document ingestion, retrieval‑augmented generation, tool integration, and MCP connectivity.
by danny-avila
Provides a self‑hosted ChatGPT‑style interface supporting numerous AI models, agents, code interpreter, image generation, multimodal interactions, and secure multi‑user authentication.
by block
Automates engineering tasks on local machines, executing code, building projects, debugging, orchestrating workflows, and interacting with external APIs using any LLM.
by RooCodeInc
Provides an autonomous AI coding partner inside the editor that can understand natural language, manipulate files, run commands, browse the web, and be customized via modes and instructions.
by pydantic
A Python framework that enables seamless integration of Pydantic validation with large language models, providing type‑safe agent construction, dependency injection, and structured output handling.
by mcp-use
A Python SDK that simplifies interaction with MCP servers and enables developers to create custom agents with tool‑calling capabilities.
by lastmile-ai
Build effective agents using Model Context Protocol and simple, composable workflow patterns.
by Klavis-AI
Provides production‑ready MCP servers and a hosted service for integrating AI applications with over 50 third‑party services via standardized APIs, OAuth, and easy Docker or hosted deployment.