Tools 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:
Read Group
File system reading and searching
Code exploration and analysis
MCP Group
External tool integration
Specialized functionality through external servers
Workflow Group
Mode and task management
Context switching and task organization
Always Available Tools
Certain tools are accessible regardless of the current mode:
ask_followup_question: Gather additional information from users
attempt_completion: Signal task completion
switch_mode: Change operational modes
new_task: Create subtasks
update_todo_list: Manage step-by-step task tracking
Available Tools
Read Tools
These tools help Kilo Code understand your code and project:
read_file - Examines the contents of files
search_files - Finds patterns across multiple files
list_files - Maps your project's file structure
list_code_definition_names - Creates a structural map of your code
Edit Tools
These tools help Kilo Code make changes to your code:
apply_diff - Makes precise, surgical changes to your code
write_to_file - Creates new files or completely rewrites existing ones
Browser Tools
These tools help Kilo Code interact with web applications:
browser_action - Automates browser interactions
Command Tools
These tools help Kilo Code execute commands:
execute_command - Runs system commands and programs
MCP Tools
These tools help Kilo Code connect with external services:
use_mcp_tool - Uses specialized external tools
access_mcp_resource - Accesses external data sources
Workflow Tools
These tools help manage the conversation and task flow:
ask_followup_question - Gets additional information from you
attempt_completion - Presents final results
switch_mode - Changes to a different mode for specialized tasks
new_task - Creates a new subtask
update_todo_list - Tracks task progress with step-by-step checklists
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
[ask_followup_question](/features/tools/ask-followup-question) → [read_file](/features/tools/read-file) → [search_files](/features/tools/search-files)
Code Modification
[read_file](/features/tools/read-file) → [apply_diff](/features/tools/apply-diff) → [attempt_completion](/features/tools/attempt-completion)
Task Management
[new_task](/features/tools/new-task) → [switch_mode](/features/tools/switch-mode) → [execute_command](/features/tools/execute-command)
Progress Tracking
[update_todo_list](/features/tools/update-todo-list) → [execute_command](/features/tools/execute-command) → [update_todo_list](/features/tools/update-todo-list)
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
Last updated