AgentDefinition Type
An agent is defined using theAgentDefinition type:
Required Fields
Unique identifier for the agent. Must contain only lowercase letters, numbers, and hyphens.
Human-readable name for the agent.
AI model to use. Can be any model from OpenRouter.Recommended models:
anthropic/claude-sonnet-4.6- Best for complex coding tasksanthropic/claude-opus-4.6- Most capable, slower and more expensiveopenai/gpt-5.3- Fast and capablegoogle/gemini-3.1-flash-lite-preview- Very fast, cost-effective
Optional Fields
Tools and Capabilities
Tools the agent can use. Available tools:File operations:
read_files- Read file contentswrite_file- Write or create filesstr_replace- Edit files with string replacementapply_patch- Apply unified diff patches
code_search- Search code using ripgrepfind_files- Find files by name patternlist_directory- List directory contentsglob- Find files using glob patterns
run_terminal_command- Run shell commands
web_search- Search the webread_docs- Read documentationspawn_agents- Spawn other agentsset_output- Set structured outputend_turn- End the agent’s turn
Other agents this agent can spawn.
Instructions
Main instructions for the agent. This is inserted after each user input.This is the most important field for shaping agent behavior.
Background information for the agent. Fairly optional.
Prompt inserted at each agent step. Powerful but usually not necessary for smart models.
Input and Output
Schema for agent inputs. Most agents only need a prompt.
How the agent outputs responses:
last_message(default) - Last message after using toolsall_messages- All messages including tool callsstructured_output- JSON object (use withoutputSchema)
JSON schema for structured output (when
outputMode: 'structured_output').Complete Example
Loading Agents from Files
For complex agents, define them in.agents directory files:

