Strength | Description |
Context retention | Each subagent runs in its own context, preventing the main conversation from being contaminated and keeping it focused on high-level goals. |
Specialized knowledge | Subagents can be fine-tuned with domain-specific detailed instructions, thereby improving the success rate of designated tasks. |
Reusability | Once created, subagents can be used across different projects and shared with your team to achieve consistent workflows. |
Flexible permissions | Each subagent can have different tool access levels, allowing you to restrict powerful tools to specific subagent types. |
/agents
e to edit the system prompt in your own editor.> Use the code-reviewer subagent to check my recent changes.
Type | Position | Scope | Priority |
Project subagent | .codebuddy/agents/ | Available in the current project | Highest |
User subagent | ~/.codebuddy/agents/ | Available in all projects | Moderately Low |
/agents page.agents/ directory (or a custom path specified in the plugin manifest)./agents page./agents page.--agents CLI flag, which accepts a JSON object:codebuddy --agents '{"code-reviewer": {"description": "Code review expert. Use proactively after code changes.","prompt": "You are a senior code reviewer. Focus on code quality, security, and best practices.","tools": ["Read", "Grep", "Glob", "Bash"],"model": "gemini-3.0-flash"}}'
---name: your-sub-agent-namedescription: Describes when this subagent should be called.tools: tool1, tool2, tool3 # Optional - If omitted, all tools are inherited.model: gpt-5.1-codex # Optional - Specify a model alias or 'inherit'.permissionMode: default # Optional - The permission mode for the subagent.skills: skill1, skill2 # Optional - Skills to load automatically.---Write the system prompt for the subagent here. It can contain multiple paragraphs.Clearly define the subagent's role, capabilities, and approach to solving problems.Include specific instructions, best practices, and any constraints that the subagent should follow.
Field | Required | Description |
name | Yes | Unique identifier using lowercase letters and hyphens |
description | Yes | Natural language description of the subagent's purpose |
tools | No | A comma-separated list of specific tools. If the list is omitted, all tools in the main thread are inherited. You can use the Defer(X) / NoDefer(X) modifiers to adjust the deferred loading state of tools. For details, see Tool Deferred Loading Override. |
model | No | A model ID, name, or alias, a scenario variant lite / reasoning, or inherit / default. When the value is omitted or set to inherit / default, no specific model is enforced, and the model continues to be selected through the normal subagent resolution chain. |
permissionMode | No | Permission mode of the subagent. Valid values: default, acceptEdits, bypassPermissions, plan, ignore. Controls how the subagent handles permission requests. |
skills | No | Names of skills automatically loaded when the subagent starts, separated by commas |
mcpServers | No | Declaration of MCP servers dedicated to the subagent. Supports referencing existing global MCP servers or declaring private inline MCP servers for the current subagent. For details, see the description below. |
disallowedTools | No | List of tools disallowed for the subagent (array or comma-separated), which takes effect as the union with the session-level disallowedTools |
effort | No | Reasoning effort: minimal / low / medium / high / xhigh / max. If the reasoning effort is omitted, the session effort is inherited. |
maxTurns | No | Maximum execution turns of the subagent (a positive integer). Priority: env CODEBUDDY_CODE_SUBAGENT_MAX_TURNS > the max_turns parameter of the Agent tool > this field. |
background | No | When set to true, the subagent always runs in the background (equivalent to the caller passing run_in_background: true); when CODEBUDDY_CODE_DISABLE_BACKGROUND_TASKS is enabled, it degrades to synchronous execution (only logs are written, with no user-visible alarm). |
initialPrompt | No | When this agent runs as the main session agent ( --agent or the settings agent), it is automatically prefixed to the first user message and injected only in the first turn of the main session. |
memory | No | Persistent memory scope: user (~/.codebuddy/agent-memory/<name>/), project (<cwd>/.codebuddy/agent-memory/<name>/), local (not stored in version control). When persistent memory is enabled, MEMORY.md is automatically injected at spawn time (truncated to 200 lines / 25 KB), and an explicit tools allowlist automatically adds Read/Write/Edit. |
tools: Agent can continue nesting.CODEBUDDY_CODE_MAX_SUBAGENTS_PER_SESSION (a positive integer that cannot be disabled). Nested spawns share the same budget, which is reset after /clear. The budget counts only spawns through the Agent tool path. The workflow/skill path constructs AgentTask directly and does not pass through this gate.<system-reminder> tags are rewritten to <\\system-reminder>, and a backslash is added to Human: / Assistant: at the beginning of a line. When a match occurs, a marker line [harness: subagent output matched ...] is added to the beginning of the report. Detoxification only inserts backslashes into matched segments and does not delete content. Tool calls induced by the report still go through normal permission checks.mcpServers is used to declare MCP servers for a subagent that are visible only while that subagent is running. It is not written to the global MCP configuration, and it is not automatically visible to the main conversation or other subagents. Two syntaxes are supported.---name: docs-searcherdescription: Use the existing docs MCP for search.tools:- ReadmcpServers:- docs---
docs here must already be a globally connected MCP server. The subagent only borrows it and does not close it when the subagent ends.---name: browser-checkerdescription: Use a private MCP for browser inspection.tools:- ToolSearch- DeferExecuteToolmcpServers:- browser_private:type: stdiocommand: nodeargs:- /absolute/path/to/browser-mcp-server.jsdefer_loading: true---
Source | mcpServers Behavior |
User subagent: ~/.codebuddy/agents/*.md | Allows inline MCP. |
Project subagent: .codebuddy/agents/*.md | Allows inline MCP, but requires local project approval. |
Plugin agent | Ignores mcpServers. |
strictMcpConfig=true | Skips all agent frontmatter/product mcpServers. |
.codebuddy/settings.local.json in the current workspace:{"enabledMcpjsonServers": ["browser_private"]}
codebuddy --settings '{"enabledMcpjsonServers":["browser_private"]}'
settings.json, because project MCP approval reads only the project-local and CLI scopes.ToolSearch and then invokes them through DeferExecuteTool.tools:- ToolSearch- DeferExecuteToolmcpServers:- finance_data:type: stdiocommand: nodeargs:- /absolute/path/to/finance-mcp-server.js
mcpServers:- finance_data:type: stdiocommand: nodeargs:- /absolute/path/to/finance-mcp-server.jsdefer_loading: false
Defer(...) / NoDefer(...) modifiers in the tools field.lite or reasoning, which are then mapped to a specific model by /model or variantModels.inherit / default, or omitted: No specific model is enforced, and resolution continues in the order of environment variables, per-invocation settings, per-subagent settings, built-in declarations, and the main conversation model.inherit is used, if no higher-priority configuration exists, the subagent ultimately inherits the main conversation model, which helps maintain consistency in features and response style./agents command to modify tool access permissions - it provides an interactive interface that lists all available tools, including any connected MCP server tools, making it easier to select the desired tools.tools field to inherit all tools from the main thread (default), including MCP tools./agents).tools field is omitted, subagents inherit all MCP tools available to the main thread./agents command provides a comprehensive interface for subagent management:/agents
/model.lite / reasoning scenario variant for a built-in subagent through Edit Model.Explore, general-purpose, and Plan) can also specify models independently at the subagent level, with no impact on each other and free combination. This resolves the previous pain point where only a one-size-fits-all approach through environment variables was possible, making differentiation impossible./agents panel:/agents, select a built-in subagent with ↑/↓, and press Enter to open its action menu.lite / reasoning./model).Tab to switch between the Global and Project save scopes, and press Enter to confirm.lite / reasoning. The specific model and source that a scenario variant ultimately maps to can be viewed through /model:lite / /model:reasoning.Source Tag | Description |
env-global | Environment variable CODEBUDDY_CODE_SUBAGENT_MODEL takes over across the board (see priority below). |
settings-project | Project-level configuration ( .codebuddy/settings.json) |
settings-user | Global configuration ( ~/.codebuddy/settings.json) |
product-default | Built-in default declaration (for example, Explore = lite) |
inherit | No declaration is made, and the main conversation model is inherited. |
fallback-main | The configured model is disabled/locally unknown, and the system falls back to the main conversation model. |
subagents.agents.<subagent_name>.model field in settings (where the key of agents is the subagent name, and model is the model ID / alias / variant / inherit / default). You can also manually edit settings.json. For details, see Settings documentation.CODEBUDDY_CODE_SUBAGENT_MODEL (a one-size-fits-all override that applies uniformly to all subagents, with the highest priority)default / lite / reasoning, effective for a single call)subagents.agents.<subagent_name>.modelsubagents.agents.<subagent_name>.modelagents[].models[0] in product.json, such as Explore = lite)CODEBUDDY_CODE_SUBAGENT_MODEL is set, the panel still allows saving per-Agent configurations without reporting an error, but it displays a message indicating that they are uniformly overridden by the environment variable. After the environment variable is removed, the per-Agent configurations take effect again.# Create a project subagentmkdir -p .codebuddy/agentsecho '---name: test-runnerdescription: Proactively run tests and fix failures---You are a test automation expert. When you see code changes, proactively run the corresponding tests.If tests fail, analyze the causes and fix them while preserving the original test intent.' > .codebuddy/agents/test-runner.md# Create a user subagentmkdir -p ~/.codebuddy/agents# ... Create the subagent file
/agents command instead.description field in the subagent configurationdescription field.> Use the test-runner subagent to fix failing tests> Have the code-reviewer subagent check my recent changes.> Ask the debugger subagent to investigate this error.
/agents.User: Find all places that handle authentication and update them to use the new token format.CodeBuddy Code: [Invoke the general-purpose subagent][The agent searches the codebase for authentication-related code.][The agent reads and analyzes multiple files.][The agent makes the necessary edits.][Return a detailed description of the changes made.]
/agents.User: [In plan mode] Help me refactor the authentication module.CodeBuddy Code: Let me first look into your authentication implementation...[Internally invokes the Plan subagent to explore authentication-related files][The Plan subagent searches the codebase and returns findings]CodeBuddy Code: Based on my research, here is my proposed plan...
lite scenario variant. The actual model is determined by the corresponding environment variable, project-level and user-level variantModels, the main model's relatedModels, and default orchestration.User: Where are client errors handled?CodeBuddy Code: [Invoke the Explore subagent with "medium" thoroughness][Explore uses Grep to search for error handling patterns][Explore uses Read to inspect potentially relevant files][Return findings with absolute file paths]CodeBuddy Code: Client errors are handled in src/services/process.ts:712...
User: What is the structure of the codebase?CodeBuddy Code: [Invoke the Explore subagent with "quick" thoroughness][Explore uses Glob and ls to map the directory structure][Return an overview of key directories and their purposes]
---name: code-reviewerdescription: Code review expert. Proactively review code quality, security, and maintainability. Use immediately after writing or modifying code.tools: Read, Grep, Glob, Bashmodel: inherit---You are a senior code reviewer who ensures high standards of code quality and security.When invoked:1. Run git diff to view recent changes2. Focus on modified files3. Start the review immediatelyReview Checklist:- Code is clear and readable.- Functions and variables are well named.- No duplicate code.- Proper error handling- No exposed secrets or API keys.- Input validation implemented.- Good test coverage- Performance issues considered.Organize feedback by priority:- Critical issues (must fix)- Warnings (should fix)- Suggestions (consider improving)Contains specific examples of how to fix the issue.
---name: debuggerdescription: Debugging expert for errors, test failures, and unexpected behavior. Use proactively when encountering any issues.tools: Read, Edit, Bash, Grep, Glob---You are an expert-level debugger specializing in root cause analysis.When invoked:1. Capture error messages and stack traces.2. Determine the reproduction steps.3. Isolate the fault location.4. Implement the minimal fix.5. Verify that the solution is effective.Debugging process:- Analyze error messages and logs.- Check recent code changes.- Form and test hypotheses.- Add strategic debug logs.- Check the variable status.For each question, provide the following:- Root cause explanation.- Evidence supporting the diagnosis.- Specific code fixes.- Test methods.- Prevention recommendations.Focus on fixing the root cause rather than just the symptoms.
---name: data-scientistdescription: Data analysis expert for SQL queries, BigQuery operations, and data insights. Use proactively for data analysis tasks and queries.tools: Bash, Read, Writemodel: gpt-5.1-codex---You are a data scientist specializing in SQL and BigQuery analytics.When invoked:1. Understand the data analysis requirements.2. Write efficient SQL queries.3. Use the BigQuery command-line tool (bq) when appropriate.4. Analyze and summarize the results.5. Present findings clearly.Key Practices:- Write optimized SQL queries with appropriate filters.- Use appropriate aggregations and joins.- Include comments that explain complex logic.- Format the results to improve readability.- Provide data-driven recommendations.For each analysis:- Explain the query method.- Document any assumptions.- Highlight key findings.- Recommend next steps based on the data.Always ensure that queries are efficient and cost-effective.
> First, use the code-analyzer subagent to identify performance issues, and then use the optimizer subagent to fix them.
description field specific and action-oriented to achieve the best results.agentId.agent-{agentId}.jsonlagentId through the resume parameter.> Start reviewing the authentication module using the code-analyzer agent.[The agent completes the initial analysis and returns agentId: "abc123"]
> Resume agent abc123 and continue analyzing the authorization logic.[The agent continues to use the full context of the previous conversation.]
subagents/ subdirectory of the parent session.resume parameter accepts an agent ID from a previous execution.~/.codebuddy/projects/{projectDir}/└── {parentSessionId}/├── tool-results/ ← Tool output files for the main session└── subagents/ ← Subagent data├── agent-{agentId}.jsonl ← Subagent conversation history└── agent-{agentId}/└── tool-results/ ← Tool output files for the subagent└── {callId}.txt
tool-results/ directory. The model receives the truncated content and a file path pointer, and can read the full content on demand. For details, see Environment Variables Reference.resume parameter:{"description": "Continue analysis","prompt": "Now check the error handling pattern","subagent_type": "code-analyzer","resume": "abc123" // Agent ID from a previous execution}
run_in_background: true parameter.TaskOutput tool to get the status and results of background tasks.> Run the code-analyzer agent in the background to review the entire codebase.[Task started in the background. Task ID: task-abc123]**Get background task output:**Use the `TaskOutput` tool to query the status and results of background tasks:
Check the status of background task task-abc123.
**Background task status:**| Status | Description || :--- | :--- || `pending` | The task has been created and is waiting to be executed. || `running` | The task is running. || `completed` | The task has been completed successfully. || `failed` | The task failed to execute. || `cancelled` | The task was cancelled by the user. || `killed` | The task was forcibly terminated. |**Programmatic Usage:**If you use the Agent SDK or interact with the Agent tool directly, you can pass the `run_in_background` parameter:```typescript{"description": "Analyze the codebase","prompt": "Review all TypeScript files for potential issues","subagent_type": "code-analyzer","run_in_background": true // Run in the background}
TaskOutput tool supports the following parameters.Parameter | Type | Description |
task_id | string | Required. ID of the background task. |
block | boolean | Whether to wait for task completion. Defaults to true. |
timeout | number | Timeout to wait in milliseconds. Defaults to 30000ms, with a maximum of 600000ms. |
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback