agent2 AGENTS.md

agent2 AGENTS.md is an instructions file for Codex, OpenCode from Artesiana/agent2. It costs 1,420 tokens per session, scanned A, original, MIT.

A guide to Agent2’s framework and command-line workflow for turning professional expertise into production AI agents. It explains the project’s services, optional components such as RAG, and its model of an agent as a professional with tools, knowledge, memory, and review steps.

In plain words
What is it for?
Use it when setting up Agent2, running its checks and tests, onboarding an agent from a specification, starting its Docker services, or designing domain-agent behavior.
Why use it?
It helps agents follow the project’s architecture and distinguish a complete result from a request for clarification or a rejection.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/artesiana/agent2/agents-md
Clone the repo
git clone --depth 1 https://github.com/Artesiana/agent2

Made for: Codex, OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for agent2 AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/artesiana/agent2/agents-md.svg)](https://agentmods.dev/instructions/artesiana/agent2/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/artesiana/agent2/agents-md"><img src="https://agentmods.dev/badge/instructions/artesiana/agent2/agents-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,420 This file is loaded in full into every session.
When invoked 1,420 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01420 $0.01420
Opus 5 $0.00710 $0.00710
Sonnet 5 $0.00284 $0.00284
Haiku 4.5 $0.00142 $0.00142

Measured 4d ago against content hash 1ec2d5e2a209, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

agent2 AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 132 lines

How it starts

The opening of the file, as written. The whole thing — 132 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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 -d

Agent2 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_validator to 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.yaml is the global source of truth for default model, provider policy, stack profile, telemetry, and framework ports.
  • Build agents with create_agent() from shared/runtime.py.
  • Build apps with create_app() from shared/api.py.
  • Use agent2 setup for local .env/agent2.yaml generation and agent2 onboard for Brain Clone agent scaffolding before hand-editing files.
  • Use instructions=, not system_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 _toolsets from before_run() are supported by the API runtime and passed to Agent.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.

Read the full file on GitHub · 132 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 132 lines · 1,420 tokens per session scan A 1ec2d5e2a209

Subscribe to this mod's changes

agent2 AGENTS.md is an instructions file published in the GitHub repository Artesiana/agent2 (36 stars, last pushed 3mo ago), licensed MIT. It adds 1,420 tokens to every session, about $0.0071 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.