Agents
Each directory under agents/ at the repo root (a sibling of amodal/) defines one agent. A named agent can root a conversation or run as a delegated specialist. The directory name is the agent's identifier.
agents/
├── main/
│ └── AGENT.md
└── compliance-checker/
├── AGENT.md # prompt, required
├── agent.json # configuration, optional
├── agent.ts # configuration with predicates, optional
└── CONTEXT.md # per-turn prompt, optionalA directory without AGENT.md is ignored.
Main agent
For a new project, set "schemaVersion": 2 in amodal.json. Write the chat instructions in agents/main/AGENT.md and declare its allowed resources in agents/main/agent.json, using the same fields as any named specialist. For example:
{
"description": "Answer questions about support tickets.",
"tools": ["load_skill"],
"skills": ["Triage"],
"connections": ["support-demo"],
"expose": { "protocols": ["mcp", "a2a"] }
}An ordinary chat, an autonomous run of main, and an external call to the published main agent all select this definition. Omit expose to keep it private. The runtime still applies each channel’s permissions. See Publish the main agent and specialists.
Migrating from version 1
Omitting schemaVersion keeps version 1 behavior. An authored agents/default/ handles ordinary chat. Without one, chat uses the whole bundle with instructions from agents/main/AGENT.md or agents/main.md. Legacy main.tools adds optional tools to that surface. A configured basePrompt replaces only the default behavior instructions; the rest of the prompt is composed around it.
When you are ready to adopt version 2:
| Current files | Migration |
|---|---|
Only main | Use agents/main/AGENT.md and list the resources main needs in its agent.json. Version 2 applies those lists as restrictions. |
Only default | Move the directory to agents/main/, retaining its settings, context, and conditional declarations. |
| Both | Choose which definition should handle ordinary chat. Keep that one as main and give the other a specialist name. Update references to renamed agents. |
If a renamed agent was published, set expose.name explicitly to preserve its client-facing name. Finish outstanding external runs before changing their target, since saved receipts are bound to the original contract. Deploy with "schemaVersion": 2 after updating the files. Version 2 rejects a remaining agents/default/ definition. The reserved simple preset is separate from chat routing.
Rooting A Conversation
Pass the directory name in the chat request's agent field:
{
"message": "Review transactions TXN-001 through TXN-050.",
"agent": "compliance-checker"
}The root agent's prompt replaces the main operating instructions. Its tools, skills, connections, stores, mcp, and subagents declarations select the available resources. Files under amodal/ still load as repo content, but the session only exposes the names the agent lists. load_knowledge is the exception: every root session gets it when the bundle has Markdown knowledge. The runtime still supplies chat protocol tools such as ask_choice.
- An unknown
agentname fails the request. It does not fall back to the default chat. - When
agentis omitted in version 2, chat usesmain. - A later turn on the same session that names a different
agentre-roots the session. The transcript is kept, and the runtime inserts an[Agent handoff] <from> -> <to>user message that lists the tools the new agent lacks. - The active root is excluded from the callable specialist list.
Skill entries use the skill's parsed name, not its folder name. See Skills. Store entries produce the tools listed in Stores.
agent.json
{
"name": "Compliance Checker",
"description": "Check transactions against the supplied compliance policy.",
"tools": ["load_knowledge", "store__research_notes__query"],
"stores": { "research-notes": "read" },
"maxToolCalls": 15,
"modelTier": "advanced"
}AGENT.md holds the prompt. If it has a ## Prompt section, that section is the prompt; otherwise the whole file is.
| Field | Default | Meaning |
|---|---|---|
name | Directory name | Display name. The directory name remains the invocation identifier. |
description | name | Description shown in the specialist list. |
tools | [] | Explicit tool names. A root session also gets load_knowledge and the chat protocol tools. |
skills | None | Skills included when the agent roots a session. Each adds its allowedTools. |
connections | None | REST connections for a root session. Native OpenAPI specialists also prepare their own declared connections. |
mcp | None | MCP servers exposed when the agent roots a session. |
subagents | None | Specialists callable from a session rooted in this agent. |
stores | None | Per-store "read" or "rw" access for a root session. See Per-Agent Access. |
maxToolCalls | 10 | Turn limit for a delegated run. One turn may call several tools. Positive integer. |
modelTier | Session model | A category from amodal.json, such as peer-review. See Model Tiers. |
maxDepth, timeout, targetOutputMin, and targetOutputMax are validated but have no runtime effect. State the required output format in the prompt.
List entries accept a name or {"name": "..."}. Store entries accept "read", "rw", or {"mode": "read"}. A conditional key in agent.json is a load error.
Configuration In AGENT.md
Without agent.json or agent.ts, AGENT.md can carry configuration in YAML frontmatter. Use displayName for the display name. The prompt is the body after the frontmatter and must not be empty.
---
displayName: Vendor Lookup
description: Look up vendor records and summarize contract status.
tools: [request]
maxToolCalls: 10
modelTier: simple
---
Query the vendor system for the named vendor. Return the company name,
contract status, source record, and any missing information.A ## Config YAML section is not parsed.
agent.ts
A sibling agent.ts accepts the same fields as agent.json and adds synchronous predicates to resource entries. It needs no Amodal package dependency:
const isManager = (ctx: { claims: Record<string, unknown> }) => ctx.claims['role'] === 'manager';
const isJoint = (ctx: { context: Record<string, string> }) => ctx.context['mission_type'] === 'joint';
export default {
tools: ['review', 'check_conflicts'],
skills: ['request-review', { name: 'joint-review', conditional: isJoint }],
subagents: ['prescreen', { name: 'adjudicator', conditional: isManager }],
stores: {
requests: 'read',
decisions: { mode: 'rw', conditional: isManager },
},
};List entries accept a name or {name, conditional}. Store entries accept "read", "rw", or {mode, conditional}. Any other key in an entry is a load error.
A predicate decides whether a declared entry is included for this caller. It cannot add an undeclared resource. It must return true to include the entry. A thrown error or missing caller context excludes it.
interface AgentSurfaceContext {
claims: Record<string, string | string[]>;
context: Record<string, string>;
scopeId: string;
userId?: string;
orgId?: string;
humanPresent: boolean;
isSubagent: boolean;
agentName: string;
}| Field | Meaning |
|---|---|
claims | Verified JWT claims. A value is a string or a list of strings. Use for authorization decisions. |
context | Merged request context, including client-supplied values. Use to select relevant workflows or resources. |
scopeId | The session's scope identifier. Empty for agent-level state. |
userId, orgId | Verified caller and organization identifiers, when available. |
humanPresent | false for cron, webhook, and channel runs where nobody can answer a confirmation. |
isSubagent | true when the agent runs as a delegated specialist. |
agentName | Name of the session's root agent, including in specialist predicates. |
In a local run, claims come from dev-users.json.
A client can send {"role": "manager"} in request context. A permission predicate must therefore read ctx.claims.role, not ctx.context.role.
A delegated specialist inherits the session's surface context with isSubagent set to true. A curation predicate that reads page state should allow delegation explicitly:
{name: 'lookup', conditional: (ctx) => ctx.isSubagent || ctx.context.page === 'requests'}Rules:
- Predicates must be synchronous and pure. Do not fetch data or change state in them.
- Excluding a skill also excludes the tools contributed by its
allowedTools, unless another declaration grants them. agent.tsfields override matchingagent.jsonfields and logagent_definition_overrides_json. Keep each field in one file.agent.tsrequires a default export. Named exports are a load error.AGENT.mdis still required.- Conditional entries resolve at session creation and are checked again on each turn. If the resolved set changes, the runtime rebuilds the session's resources and keeps the conversation.
CONTEXT.md
AGENT.md renders once when the session is built, so values in it stay fixed. Put facts that change while the user works in CONTEXT.md, which renders on each turn after the cached prompt prefix.
Both files use Nunjucks and read request context as scope:
{% if scope.request_status %}
Request status: {{ scope.request_status }}.
{% endif %}Send the context with each chat request:
{
"message": "Why has this not been approved?",
"agent": "requests",
"context": {
"mission_id": "m-42",
"request_status": "Pending review"
}
}CONTEXT.mdis read when its agent roots the conversation, includingdefault. It is not read formainor for a delegated specialist.- Keys must start with a letter or underscore and contain at most 64 letters, digits, or underscores. Other keys are dropped.
- Values are strings and inert text. Template syntax inside a value is not executed.
"false"and"0"are truthy. - Empty and whitespace-only values are dropped.
- Values have no length cap. The runtime logs
prompt_template_scope_largeabove 100,000 total characters. - Wrap literal template syntax in
{% raw %}...{% endraw %}.
Prompt text does not enforce permissions. Use a predicate on verified claims to gate a capability, and a tool call for data that must be checked against a server.
Delegation
The root agent calls call_subagent with one or more named tasks:
call_subagent({
calls: [
{
subagent: 'compliance-checker',
task: 'Check transactions TXN-001 through TXN-050 against the compliance policy.',
input: { policy: 'aml-2026' },
},
],
});- Each call accepts at most 12 tasks and runs at most five concurrently.
- A single task returns
{subagent, result}or{subagent, error}. A batch returns{results: [...]}in call order. One failed specialist does not fail the batch. - Nested delegation stops at five levels.
- Specialists run without an interactive approval handler. A tool call that requires confirmation is denied.
- A failing tool returns an error to the specialist's model. A provider failure fails the specialist.
- From 65% of
maxToolCalls, each tool result carries a_budgetnotice with the turns left. Non-object results are wrapped as{result, _budget}.
Context Isolation
A specialist receives its own prompt as the system prompt, the task, the optional input appended as a JSON block, and any attachments a composite tool forwards. It does not receive the parent's prompt, skill bodies, or conversation history. Name every tool it needs, including load_knowledge or load_skill. A declared tool is copied from the parent session's registry, so it must exist there. Declared file tools are the exception: the runtime builds them for the specialist. See Tools for tool names.
Model Tiers
Set modelTier on a specialist to the name of a category under models in the version 2 manifest. For example, "modelTier": "peer-review" selects models.peer-review. The same selection applies to direct calls, published MCP and A2A calls, and nested delegation with ctx.callSubagent. An omitted or unbound category uses the run’s main model, including when a specialist delegates to another specialist. See Model selection.