Skip to content
AGH RuntimeConfiguration

AGENT.md

Complete implemented AGENT.md schema, parser rules, provider examples, MCP sidecars, and RFC drift.

Audience
Operators running durable agent work
Focus
Configuration guidance shaped for scanability, day-two clarity, and operator context.

AGENT.md defines an AGH agent: structured frontmatter plus a required Markdown prompt body. Current AGH agents live in AGH resource directories, not in the draft RFC .agents directory:

$AGH_HOME/agents/<agent-name>/AGENT.md
<workspace>/.agh/agents/<agent-name>/AGENT.md
<additional-root>/.agh/agents/<agent-name>/AGENT.md

The parser is strict. Unknown frontmatter fields fail loading.

Quick Reference

FieldTypeDefaultValid valuesDescription
namestringrequiredNon-empty. Must match the requested agent name when loaded by name.Agent identity and discovery key.
providerstring[defaults].providerBuilt-in provider key or custom provider key.Provider used to resolve command, model, and API key metadata.
commandstringProvider commandNon-empty when overriding.Agent-specific ACP launch command.
modelstringProvider default_modelAny string.Agent-specific model metadata.
toolsstring arrayemptyExact canonical ToolIDs or namespace-prefix wildcards.Additional agent tool allowlist grammar.
toolsetsstring arrayemptyCanonical ToolsetIDs.Additional named tool bundles allowed for the agent.
deny_toolsstring arrayemptyExact canonical ToolIDs or namespace-prefix wildcards.Tool denies that always narrow the agent grants.
permissionsstring[permissions].mode, default approve-alldeny-all, approve-reads, approve-allAgent-specific permission mode.
mcp_serversarray of MCP server objectsemptyEach object requires name and command.Agent-local MCP servers.
hooksarray of hook declarationsemptySame declaration shape as config hooks.Agent-scoped hook declarations.
Markdown bodyMarkdown textrequiredNon-empty after trimming.Startup prompt sent as the agent system prompt.

Even when tools and toolsets are empty, AGH adds the discovery toolsets agh__bootstrap and agh__catalog at runtime unless effective policy denies them. Agents should discover AGH-native runtime capabilities with agh__tool_search, inspect descriptors with agh__tool_info, and invoke dedicated tools before shelling out to equivalent agh ... commands. Operator-only management flows — daemon lifecycle, MCP OAuth login/logout, raw secret writes, and trust-root config — remain CLI/HTTP/UDS by design and are not promoted into the tool surface.

Discovery And Precedence

AGH loads visible agents from the workspace snapshot attached to a session.

OrderSourcePath
1Workspace root<workspace>/.agh/agents/<name>/AGENT.md
2Additional roots<additional-root>/.agh/agents/<name>/AGENT.md, in registered order
3Global home$AGH_HOME/agents/<name>/AGENT.md

Discovery is first-wins. If two files define the same name, AGH keeps the first one found and does not merge lower-precedence definitions.

Parser Rules

RuleBehavior
Frontmatter delimiterThe file must start with --- and include a closing ---.
Frontmatter languageYAML is parsed first. If YAML fails, AGH tries TOML frontmatter.
Unknown fieldsUnknown YAML or TOML fields are errors.
BodyThe Markdown body after frontmatter is trimmed. Empty body fails with agent prompt is required.
Name matchLoadAgentDef(name) requires the parsed name to match the requested directory/name.
Sidecarmcp.json next to AGENT.md is optional and replaces same-name inline MCP servers as whole objects.

Complete Annotated Example

---
# Required. This must match the directory name when loaded by name.
name: reviewer

# Optional if [defaults].provider is set in config.toml.
provider: claude

# Optional. Defaults to the provider default_model.
model: claude-sonnet-4-6

# Optional. Add only extra ToolIDs beyond default discovery.
tools:
  - "mcp__github__*"

# Optional. Add only extra toolsets beyond agh__bootstrap + agh__catalog defaults.
toolsets:
  - "agh__coordination"

# Optional. Denies always narrow the allowed set.
deny_tools:
  - "agh__network_send"

# Optional. Defaults to [permissions].mode.
permissions: approve-reads

# Optional. Merged after top-level and provider MCP servers.
mcp_servers:
  - name: github
    command: npx
    args: ["-y", "@modelcontextprotocol/server-github"]
    secret_env:
      GITHUB_TOKEN: "env:GITHUB_TOKEN"

# Optional. Agent-scoped hooks automatically match this agent name.
hooks:
  - name: reviewer-started
    event: session.post_create
    mode: async
    command: printf
    args: ["reviewer ready\n"]
---

You are a senior code reviewer.

Review code for correctness, security boundaries, data loss, races, and missing tests.
Put blocking findings first and cite the relevant file or symbol.

Field Details

name

AttributeValue
Typestring
Defaultnone
Requiredyes
Valid valuesNon-empty string. No lowercase or slug pattern is currently enforced.
DescriptionAgent identity used for discovery, CLI/API selection, hook scoping, and duplicate resolution.

provider

AttributeValue
Typestring
Default[defaults].provider
RequiredRequired at resolution time unless [defaults].provider is set.
Valid valuesBuilt-in provider key or custom [providers.<name>] key.
DescriptionSelects the provider command, default model, provider MCP servers, and API key environment metadata.

command

AttributeValue
Typestring
DefaultSelected provider command
Requiredno
Valid valuesNon-empty command when set.
DescriptionOverrides the provider launch command for this agent. The command is parsed with shell-style quoting and launched without a shell.

model

AttributeValue
Typestring
DefaultSelected provider default_model
Requiredno
Valid valuesAny string. Empty is allowed if the provider has no default.
DescriptionAgent-specific model metadata.

tools

AttributeValue
Typestring array
Defaultempty
Requiredno
Valid valuesExact canonical ToolIDs such as agh__skill_view, or namespace-prefix wildcards such as agh__skill_* and mcp__github__*. *, dotted names, hyphens, uppercase, suffix wildcards, and mid-segment wildcards are rejected.
DescriptionAdditional agent tool allowlist grammar consumed by the registry policy layer. It does not raise authority above [permissions].mode; default discovery still comes from the runtime overlay unless denied.

toolsets

AttributeValue
Typestring array
Defaultempty
Requiredno
Valid valuesCanonical ToolsetIDs such as agh__catalog or linear__read.
DescriptionAdditional named tool bundles allowed for the agent. Toolsets are separate from tools; do not place toolset IDs in tools. AGH adds agh__bootstrap and agh__catalog at runtime by default unless denied.

deny_tools

AttributeValue
Typestring array
Defaultempty
Requiredno
Valid valuesSame grammar as tools: exact canonical ToolIDs or namespace-prefix wildcard patterns.
DescriptionExplicit narrowing layer. A deny can overlap an allow; later policy evaluation treats the deny as taking precedence.

permissions

AttributeValue
Typestring
Default[permissions].mode, which defaults to approve-all
Requiredno
Valid valuesdeny-all, approve-reads, approve-all
DescriptionOverrides the global permission mode for this agent.

mcp_servers

AttributeValue
Typearray of MCP server objects
Defaultempty
Requiredno
Valid valuesEach object requires name and command; args and env are optional.
DescriptionAgent-local MCP servers merged after top-level config and provider MCP servers.
Server fieldTypeDefaultValid valuesDescription
namestringrequiredNon-empty.Server merge key.
commandstringrequiredNon-empty.MCP server command.
argsstring arrayemptyStrings.Command arguments.
envstring mapemptyString keys and values.Literal environment values. No shell expansion is performed.

hooks

Agent hook declarations use the same fields as [[hooks.declarations]] in config.toml. When a hook matcher includes agent_name, it must match this agent's name; AGH then scopes the hook to this agent.

FieldTypeDefaultValid valuesDescription
namestringrequiredNon-empty.Hook name.
eventstringrequiredCurrent dot-form hook event.Event that triggers the hook.
modestringasyncsync or async; sync only for sync-eligible events.Dispatch mode.
requiredbooleanfalsetrue or false; required hooks must be sync.Whether hook failure blocks the source operation.
priorityintegerAgent-definition source default.Integer.Ordering priority.
timeoutduration0s; subprocess executor uses 5 seconds when zero.Non-negative Go duration.Hook timeout.
matcherobjectscoped to this agent.Hook matcher fields.Narrows eligibility.
commandstringemptyRequired for subprocess hooks unless nested executor fields are used.Subprocess command.
argsstring arrayemptyStrings.Command arguments.
envstring mapemptyString keys and values.Explicit hook environment values.
executor.kindstringsubprocess when a command is present.subprocess or wasm for user declarations.Executor kind.

Provider Examples

These snippets show the minimal agent shape for the core built-in providers. API-key providers such as OpenRouter, z.ai, Moonshot/Kimi, and Vercel AI Gateway use the same provider and model frontmatter once their credential slots are configured in config.toml or settings.

Claude

---
name: claude-reviewer
provider: claude
model: claude-sonnet-4-6
permissions: approve-reads
---

Review the requested change for correctness and missing tests.

Codex

---
name: codex-builder
provider: codex
model: gpt-5.4
permissions: approve-all
---

Implement scoped code changes, run verification, and summarize the diff.

Gemini

---
name: gemini-researcher
provider: gemini
model: gemini-3.1-pro-preview
permissions: approve-reads
---

Analyze the repository context and return concise implementation guidance.

OpenCode

---
name: opencode-worker
provider: opencode
permissions: approve-all
---

Work through implementation tasks with a small, reviewable diff.

Copilot

---
name: copilot-helper
provider: copilot
permissions: approve-reads
---

Inspect the codebase and answer questions with file-backed references.

Cursor

---
name: cursor-agent
provider: cursor
permissions: approve-all
---

Make focused edits and keep changes aligned with project conventions.

Kiro

---
name: kiro-planner
provider: kiro
permissions: approve-reads
---

Turn product requirements into concrete implementation notes.

Pi

---
name: pi-assistant
provider: pi
permissions: approve-reads
---

Provide concise assistance grounded in the active workspace.

Recognized Sidecars

An agent directory accepts two kinds of sidecars next to AGENT.md:

SidecarPurposeReference
mcp.jsonDeclare MCP servers in JSON form.MCP Sidecar below.
capabilities.toml / capabilities.json or capabilities/*.toml / capabilities/*.jsonDeclare the unified capability catalog projected into brief discovery, rich discovery, and kind:"capability" transfer.Agent Capabilities.

Sidecars are loaded independently. Exactly one capability layout (single-file or directory) is allowed per agent; mixing layouts is a hard error.

MCP Sidecar

Place mcp.json next to AGENT.md when MCP definitions are generated or easier to maintain as JSON.

~/.agh/agents/reviewer/
  AGENT.md
  mcp.json
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "secret_env": {
        "GITHUB_TOKEN": "env:GITHUB_TOKEN"
      }
    }
  }
}

Sidecar behavior:

RuleBehavior
Accepted top-level keysmcpServers and mcp_servers.
Server namesThe map keys are server names.
Unknown fieldsFail parsing.
Same-name inline serverThe sidecar replaces the whole inline server object.
Missing fileTreated as absent.

Runtime Resolution

Runtime valueResolution orderFailure mode
Agent nameexplicit CLI/API agent name, then [defaults].agentFails if empty.
ProviderAGENT.md provider, then [defaults].providerFails if still empty.
CommandAGENT.md command, then provider commandFails if empty after provider resolution.
ModelAGENT.md model, then provider default_modelEmpty is allowed.
ToolsAGENT.md toolsMust be exact canonical ToolIDs or approved namespace-prefix wildcards.
ToolsetsAGENT.md toolsetsMust be canonical ToolsetIDs.
Deny toolsAGENT.md deny_toolsSame grammar as tools; denies narrow later policy evaluation.
PermissionsAGENT.md permissions, then [permissions].modeMust be a supported permission mode.
MCP serversTop-level config, provider, agent, active skillsSame-name TOML entries merge fields; JSON sidecars replace whole objects.

The Tools and Toolsets rows describe configured agent policy. Effective runtime discovery also adds agh__bootstrap and agh__catalog by default. Denies still win after that overlay.

RFC 001 Fields Not Accepted Today

The current parser rejects these draft RFC fields as unknown.

FieldRFC purposeCurrent behavior
descriptionHuman description.Rejected.
skills.inheritControl inherited skills.Rejected.
skills.disabledDisable inherited skills for one agent.Rejected.
skills.extra_sourcesAdd agent-specific skill roots.Rejected.
memory.inheritControl inherited memory.Rejected.
memory.scopeDefault write scope for memory.Rejected.
memory.auto_consolidateAgent-scoped memory consolidation.Rejected.

RFC examples also use permission values such as plan and paths such as .agents/<name>/AGENT.md. Current AGH uses deny-all, approve-reads, approve-all and .agh/agents/<name>/AGENT.md.

Common Errors

ErrorCauseFix
config: missing YAML frontmatterThe file does not start with a frontmatter block.Add an opening and closing --- block.
config: unterminated YAML frontmatterThe opening delimiter has no closing delimiter.Close the frontmatter before the prompt body.
unknown fieldA draft or misspelled frontmatter field is present.Remove it or move the setting to a supported config surface.
agent prompt is requiredThe body after frontmatter is empty.Add the agent prompt.
agent.permissions must be one of ...Unsupported permission value.Use deny-all, approve-reads, or approve-all.
provider "<name>" command is requiredA custom provider has no command.Add [providers.<name>].command or set command in AGENT.md.

On this page