agent2
AGENTS.md36 starsChanged 7 months agoMITView on GitHub
Agent2 turns domain experts into production AI agents. The goal is not to build deterministic scripts with a thin prompt on top. The goal is to clone how a professional works: their workspace, books, tools, memory, review process, judgment calls, clarification loops, and final typed work product. Read llms.txt for the compact map and llms-full.txt for expanded framework context. - A domain agent is a professional at a desk, not a rules engine. - The prompt teaches the expert's Sachbearbeiter…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 33,398 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository28 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- llms-full.txtllms.txt
- llms.txtllms.txt
- adding-capabilitiesSkill
- adding-knowledgeSkill
- agent-qaSkill
- brain-cloneSkill
- building-domain-expertsSkill
- creating-agentsSkill
- debugging-agentsSkill
- scandal-market-agent-builderSkill
- adding-capabilitiesSkill
- adding-knowledgeSkill
- agent-qaSkill
- brain-cloneSkill
- building-domain-expertsSkill
- creating-agentsSkill
- debugging-agentsSkill
- scandal-market-agent-builderSkill
- adding-capabilitiesSkill
- adding-knowledgeSkill
- agent-qaSkill
- brain-cloneSkill
- building-domain-expertsSkill
- creating-agentsSkill
- debugging-agentsSkill
- scandal-market-agent-builderSkill
The file
We split this AGENTS.md into the rules it gives an agent
9 rules. About 0 are common, 3 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Read llms.txt for the compact map and llms-full.txt for expanded framework context.
- Distinctive: line 35
Every serious domain agent should have three mutually exclusive outcomes: complete/approved, needs_clarification, or rejected.
- Very specific: line 52
Use agent2 setup for local .env/agent2.yaml generation and agent2 onboard for Brain Clone agent scaffolding before hand-editing files.
- Very specific: line 54
Use instructions=, not system_prompt=, for new code.
- Very specific: line 56
Use toolsets=[] when no MCP tools are attached.
- Very specific: line 57
Use before_run() for dynamic _instructions, request-scoped knowledge collections, resume hints, input guards, and per-run _toolsets.
- Distinctive: line 109
Use these skills when working in Claude Code, Codex, Cursor, or similar tools:
- Very specific: line 119
When building a domain expert, start from /brain-clone and study agents/procurement-compliance-officer.
- Distinctive: line 130
If the agent makes wrong domain decisions, fix books, chunking, prompt, or evals first.
≈ “Common” is an estimate: at least 1 in 5 of the 43,423 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent2
Agent2 turns domain experts into production AI agents. The goal is not to build deterministic scripts with a thin prompt on top. The goal is to clone how a professional works: their workspace, books, tools, memory, review process, judgment calls, clarification loops, and final typed work product.
Read llms.txt for the compact map and
llms-full.txt for expanded framework context.
Build and test
uv sync --extra dev
uv run pytest tests/ -v
# Agent2 v0.3 CLI
uv run agent2 setup --dry-run
uv run agent2 onboard --from-spec tests/fixtures/roofing-agent-spec.json --no-llm --overwrite
uv run agent2 doctor --json
# Core stack
docker compose up -d
# Full stack with RAG, Knowledge MCP, OCR, and full-pattern examples
docker compose --profile full up -dAgent2 mental model
- A domain agent is a professional at a desk, not a rules engine.
- The prompt teaches the expert's Sachbearbeiter Chain-of-Thought; books contain what the expert knows.
- Domain knowledge belongs in R2R knowledge collections, not hardcoded lookup tables or giant prompts.
- Every serious domain agent should have three mutually exclusive outcomes: complete/approved, needs_clarification, or rejected.
- Pydantic schemas are contracts. Use
model_validatorto prevent contradictory states such as approved plus rejection reason. - Side effects are sandboxed. Agents propose
pending_actions; hosts or humans execute them through the approval workflow. - Multi-turn work resumes through
message_history, not by reprocessing the case from scratch.
Runtime rules
shared/is framework code.- Agent business logic lives in
agents/<name>/. agent2.yamlis the global source of truth for default model, provider policy, stack profile, telemetry, and framework ports.- Build agents with
create_agent()fromshared/runtime.py. - Build apps with
create_app()fromshared/api.py. - Use
agent2 setupfor local.env/agent2.yamlgeneration andagent2 onboardfor Brain Clone agent scaffolding before hand-editing files. - Use
instructions=, notsystem_prompt=, for new code. system_prompt=exists only as a compatibility alias.- Use
toolsets=[]when no MCP tools are attached. - Use
before_run()for dynamic_instructions, request-scoped knowledge collections, resume hints, input guards, and per-run_toolsets. - Per-run
_toolsetsfrombefore_run()are supported by the API runtime and passed toAgent.run(toolsets=...); they are stripped from the user prompt. - Model resolution order is explicit runtime argument, agent
config.yaml,agent2.yaml, then env fallback. - Errors must be RFC 7807
application/problem+json.
Canonical examples
agents/procurement-compliance-officer: full Agent2 flagship. It uses the Brain Clone pattern, Knowledge MCP, per-run scoped toolsets, workspace prompt, memory tools, three outcomes, schema validators, sandbox approvals, resume,after_run, mock mode, and Promptfoo evals.docs/reference-agents/sachbearbeiter-pattern.md: explains the production-proven Sachbearbeiter pattern: one expert handles a complete case from document intake through review, communication, and final structured output.approval-demo,resume-demo,provider-policy-demo, andscoped-tools-demoare framework primitive demos.example-agent,support-ticket,code-review,invoice, andrag-testare small reference demos, not the standard for full domain experts.
Definition of done for new domain agents
A new serious Agent2 domain agent is not complete until it has:
schemas.pywith typed output, three outcomes, confidence, observablereasoning,review_steps,pending_actions, andmodel_validator.agent.pywith identity, workspace/tool metaphors, Sachbearbeiter Chain-of-Thought, example cases, outcome rules,before_run,after_run, andmock_result.tools.pywith domain-named tools. Tools return errors as data where the agent can recover.- Knowledge collections in
knowledge/collections.yamland real seed documents underknowledge/books/<collection>/. - Sandbox tools for side effects and an
execute_action()handler. - Docker Compose wiring and config
capabilities. - Focused tests for schema consistency, runtime hooks, and mock behavior.
- Promptfoo evals that test real domain behavior, not just JSON shape.
Project structure
shared/: framework runtime, API, auth, approvals, message history, tool policies, Knowledge MCP.agents/: agent services and demos.knowledge/: collection catalog and source documents.docs/: framework and pattern documentation.tests/: unit, integration-oriented, and eval support.
AI-assisted development skills
Use these skills when working in Claude Code, Codex, Cursor, or similar tools:
/brain-clone: recommended starting point for domain expert agents./creating-agents: scaffolds an Agent2 service./building-domain-experts: documents the professional-workspace pattern./adding-knowledge: adds R2R collections and Knowledge MCP wiring./adding-capabilities: adds resume, approval, provider policy, scoping, or knowledge search./debugging-agents: systematic diagnosis for runtime/config/test issues.
When building a domain expert, start from /brain-clone and study
agents/procurement-compliance-officer.
Common gotchas
- Source layout and Docker layout both need to work for agent imports.
inputon/tasksmust be a JSON object.- User-supplied
_instructionsand_toolsetsare ignored unless a runtime hook injects them. toolsets=[]is safe; avoidtoolsets=None.- Knowledge MCP belongs to the
fullprofile because it depends on R2R. - If the agent makes wrong domain decisions, fix books, chunking, prompt, or evals first. Do not add hidden deterministic lookup tables as the default fix.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

