Tool Use Overview
Kilo Code implements a sophisticated tool system that allows AI models to interact with your development environment in a controlled and secure manner. This document explains how tools work, when they're called, and how they're managed.
Core Concepts
Tool Groups
Tools are organized into logical groups based on their functionality:
| Category | Purpose | Tools | Common Use |
|---|---|---|---|
| Read Group | File system reading and searching | read, glob, grep | Code exploration and analysis |
| Edit Group | File system modifications | edit, write, apply_patch | Code changes and file manipulation |
| Execute Group | Shell command execution | bash | Running scripts, building projects |
| Web Group | Fetch and search web content | webfetch, websearch | Research, documentation lookup |
| Browser Preview | Agent Manager's built-in browser preview | browser_open | Previewing and checking locally running apps |
| MCP Group | External tool integration | MCP server tools (namespaced as {server}_{tool}) | Specialized functionality via MCP |
| Workflow Group | Sub-agents and task management | question, task, todowrite, todoread, plan, skill, agent_manager, board_post, board_read | Context switching and task organization |
Always Available Tools
Certain tools are accessible regardless of the current agent:
question: Ask the user a clarifying question with selectable optionstask: Spawn a sub-agent sessiontodowrite/todoread: Manage session task lists
Available Tools
Read Tools
These tools help Kilo Code understand your code and project:
read- Reads file contents with line numbersglob- Finds files matching a glob patterngrep- Searches file contents with regex
Edit Tools
These tools help Kilo Code make changes to your code:
edit- Makes precise text replacements in a filewrite- Creates new files or fully overwrites existing onesapply_patch- Applies unified diffs (used with certain models)
For multiple replacements in one file, Kilo uses repeated edit calls or a patch-style edit when the model supports it.
Execute Tools
These tools help Kilo Code run commands:
bash- Runs shell commands with configurable timeout and working directory
The interactive_terminal tool and the in-session terminal controls were removed, along with their API endpoints and SDK types. Run commands that need keyboard input in your own terminal, and use the bash tool for non-interactive shell commands. See Shell Integration for details.
Web Tools
These tools help Kilo Code access web content:
webfetch- Fetches a URL and returns the contentwebsearch- Searches the web
Web Search Availability
websearch is available automatically with the Kilo provider. For models from other providers it is off by default; enable it for all providers by setting web_search in kilo.jsonc:
{
"web_search": true
}
In the VS Code extension, the same option lives under Settings → Web Tools → Web Search → Enable for All Providers. The KILO_ENABLE_EXA and KILO_ENABLE_PARALLEL environment flags also enable it.
Web Search Providers
websearch routes through the Exa or Parallel search providers. When the Exa provider is used and you are signed into Kilo, requests go through the Kilo proxy automatically — no separate Exa API key is required. Setting EXA_API_KEY uses your own Exa key instead. Exa searches return at most 10 results.
Set the KILO_WEBSEARCH_PROVIDER environment variable to force a provider:
| Value | Behavior |
|---|---|
exa | Use Exa — through the Kilo proxy when signed in, through EXA_API_KEY when set |
parallel | Use Parallel |
kilo-exa | Always route Exa searches through the Kilo proxy (requires Kilo sign-in) |
Browser Tools
The VS Code extension has a built-in browser automation tool powered by Playwright MCP. Enable it in Settings → Web Tools → Browser Automation. When enabled, it registers an MCP server named kilo-playwright and exposes browser tools that follow the same permission model as all MCP tools.
The VS Code extension's experimental browser_open tool opens a local application in Agent Manager's Integrated Browser panel and returns a screenshot and diagnostics. Enable Integrated Browser under Settings > Experimental. It requires installed Chrome or compatible Playwright Chromium. It is independent from Playwright MCP.
The browser_open automation browser accepts HTTP URLs on localhost or 127.0.0.1 only, and blocks resources from other origins. See Browser previews for setup and element feedback.
This restriction is specific to browser_open, not Kilo's web access in general. Use websearch and webfetch to find and read public web pages. Browser tools from a separately configured MCP server can provide interactive web browsing according to that server's capabilities and permissions.
MCP Tools
MCP server tools are automatically available when an MCP server is connected. Tool names are namespaced as {server}_{tool}. See MCP Overview for details.
Workflow Tools
These tools help manage the conversation and task flow:
question- Asks you a clarifying question with selectable optionstask- Spawns a sub-agent (child session)todowrite- Creates and updates a session TODO listtodoread- Reads the current session TODO listplan- Enters structured planning modeskill- Invokes a reusable skill (Markdown instruction module)open_plan- Opens a saved plan for review in the VS Code extensionagent_manager- Starts Agent Manager local or worktree sessions in VS Codeboard_post/board_read- Exchange messages on the Kilo Swarm board
Task tool
Full-tool primary agents can use task to delegate a focused subtask without switching to the deprecated orchestrator agent. A task child runs in a separate session and transcript, but it uses the same project directory or worktree as its parent. task does not create a git worktree.
Task children are non-interactive delegates. They cannot ask the end user a question directly, but they can use the tools allowed by their agent and session permissions. Their result is returned to the parent session, and the child transcript can be inspected from its task card in VS Code.
There are two execution modes:
| Mode | Behavior | Use it when |
|---|---|---|
| Foreground (default) | The parent waits for the child and receives its result before continuing. | Later work depends on the child output. |
Background (background: true) | The tool returns immediately. Kilo delivers a completion or error result to the parent session when the child finishes. | The work is independent and can run while the parent continues. |
For example, a primary agent can start independent background research with a call shaped like this:
{
"description": "Audit API routes",
"prompt": "Inspect the API routes and report authentication risks. Do not edit files.",
"subagent_type": "explore",
"background": true
}
Background subagents are available when the server exposes the background capability. Do not poll for progress or duplicate work in the same files. If Kilo returns a task_id after a failed or interrupted child, use it to resume that child when the current session and permissions allow it. A child can create more task children only when its configured depth and task permission allow it.
Kilo Swarm board tools
Kilo Swarm is a shared board for one main session and its task descendants, including nested descendants. It is on by default; turn it off in Settings > Agent Behaviour or set shared_agent_board to false in kilo.jsonc. The board is not shared by unrelated sessions, even when they use the same repository or worktree.
board_poststores a concise material update for another participant. Use it for findings, questions, results, blockers, or corrections.board_readreads board messages explicitly. Use the cursor from the previous read for incremental reads instead of polling.- Board activity notices are best-effort and do not prove that a recipient read or acted on a message.
- Board messages are coordination data, not user approval. Posting does not start, wake, assign, resume, stop, or cancel an agent.
See Kilo Swarm communication for how the board relates to background agents and Agent Manager sessions.
Agent Manager tool
The agent_manager tool is available in the VS Code extension. It creates visible Agent Manager sessions in either isolated worktree mode or shared local mode, and it can inspect and control existing sessions. Use it when you need separate branches, separate terminals, or multiple independent conversations. Use task when a child should remain part of the current session's task tree.
For existing sessions, call action: "list" to discover exact session, worktree, and section IDs before using prompt, stop, move, or answer. A targeted prompt is queued for a busy session and returns when accepted; it does not wait for the session to finish or broadcast to other sessions. See Starting and orchestrating sessions from chat for the full workflow.
Tool Calling Mechanism
When Tools Are Called
Tools are invoked under specific conditions:
Direct Task Requirements
- When specific actions are needed to complete a task as decided by the LLM
- In response to user requests
- During automated workflows
Mode-Based Availability
- Different modes enable different tool sets
- Mode switches can trigger tool availability changes
- Some tools are restricted to specific modes
Context-Dependent Calls
- Based on the current state of the workspace
- In response to system events
- During error handling and recovery
Decision Process
The system uses a multi-step process to determine tool availability:
Mode Validation
isToolAllowedForMode( tool: string, modeSlug: string, customModes: ModeConfig[], toolRequirements?: Record<string, boolean>, toolParams?: Record<string, any> )Requirement Checking
- System capability verification
- Resource availability
- Permission validation
Parameter Validation
- Required parameter presence
- Parameter type checking
- Value validation
Technical Implementation
Tool Call Processing
Initialization
- Tool name and parameters are validated
- Mode compatibility is checked
- Requirements are verified
Execution
const toolCall = { type: "tool_call", name: chunk.name, arguments: chunk.input, callId: chunk.callId, }Result Handling
- Success/failure determination
- Result formatting
- Error handling
Security and Permissions
Access Control
- File system restrictions
- Command execution limitations
- Network access controls
Validation Layers
- Tool-specific validation
- Mode-based restrictions
- System-level checks
Mode Integration
Mode-Based Tool Access
Tools are made available based on the current mode:
- Code Mode: Full access to file system tools, code editing capabilities, command execution
- Ask Mode: Limited to reading tools, information gathering capabilities, no file system modifications
- Architect Mode: Design-focused tools, documentation capabilities, limited execution rights
- Custom Modes: Can be configured with specific tool access for specialized workflows
Mode Switching
Process
- Current mode state preservation
- Tool availability updates
- Context switching
Impact on Tools
- Tool set changes
- Permission adjustments
- Context preservation
Best Practices
Tool Usage Guidelines
Efficiency
- Use the most specific tool for the task
- Avoid redundant tool calls
- Batch operations when possible
Security
- Validate inputs before tool calls
- Use minimum required permissions
- Follow security best practices
Error Handling
- Implement proper error checking
- Provide meaningful error messages
- Handle failures gracefully
Common Patterns
Information Gathering
`question` → `read` → `grep`
Code Modification
`read` → `edit` → final response
Task Management
`task` → `bash` → final response
Progress Tracking
`todowrite` → `bash` → `todowrite`
Error Handling and Recovery
Error Types
Tool-Specific Errors
- Parameter validation failures
- Execution errors
- Resource access issues
System Errors
- Permission denied
- Resource unavailable
- Network failures
Context Errors
- Invalid mode for tool
- Missing requirements
- State inconsistencies
Recovery Strategies
Automatic Recovery
- Retry mechanisms
- Fallback options
- State restoration
User Intervention
- Error notifications
- Recovery suggestions
- Manual intervention options