6.2 KiB
Agent Configuration System
Overview
Kode's Agent system allows you to create specialized AI agents with predefined configurations, tools, and prompts. This enables more efficient task execution by using purpose-built agents for specific types of work.
New in this version: Use @run-agent-name for intelligent delegation with auto-completion support.
Features
- Dynamic Agent Loading: Agents are loaded from configuration files at runtime
- Five-tier Priority System: Built-in < .claude (user) < .kode (user) < .claude (project) < .kode (project)
- Hot Reload: Agent files monitored via Node.js fs.watch with cache invalidation
- Tool Restrictions: Limit agents to specific tools for security and focus
- Model Selection: Each agent can specify its preferred AI model
- Interactive Management: Use
/agentscommand for graphical management
Quick Start
Using Pre-configured Agents
Kode has one built-in agent:
@run-agent-general-purpose Find all TypeScript test files
@run-agent-my-custom-agent Implement a new user authentication feature
Managing Agents
Use the /agents command in the Kode REPL to manage agents:
kode
> /agents
This opens an interactive UI where you can:
- View all available agents
- Create new agents
- Edit existing agents
- Delete custom agents
Keyboard shortcuts:
c- Create new agentr- Reload agentsd- Delete selected agent (when viewing)qorEsc- Exit
Agent Configuration
File Structure
Agents are defined as Markdown files with YAML frontmatter:
---
name: agent-name
description: "When to use this agent"
tools: ["Tool1", "Tool2", "Tool3"] # or "*" for all tools
model_name: model-name # optional (preferred over deprecated 'model' field)
---
System prompt content goes here...
Note: Use model_name to specify the AI model. The deprecated model field is ignored.
Configuration Locations
Agents can be defined at five levels with priority order (later overrides earlier):
-
Built-in (lowest priority)
- Provided with Kode
- Cannot be modified
-
.claude User (Claude Code) (
~/.claude/agents/)- Compatibility with Claude Code user directories
- Personal agents available across all projects
-
Kode User (
~/.kode/agents/)- Kode-specific user-level agents
- Overrides Claude user agents with same name
- Create with
/agentscommand or manually
-
.claude Project (Claude Code) (
./.claude/agents/)- Compatibility with Claude Code project directories
- Overrides user-level agents
-
Kode Project (
./.kode/agents/)- Kode-specific project agents
- Highest priority, overrides all others
Example: Creating a Custom Agent
1. Manual Creation
Create a file ~/.kode/agents/api-designer.md:
---
name: api-designer
description: "Designs RESTful APIs and GraphQL schemas with best practices"
tools: ["FileRead", "FileWrite", "Grep"]
model_name: reasoning
---
You are an API design specialist. Your expertise includes:
- Designing RESTful APIs following OpenAPI specifications
- Creating GraphQL schemas with efficient resolvers
- Implementing proper authentication and authorization
- Ensuring API versioning and backward compatibility
- Writing comprehensive API documentation
Design principles:
- Follow REST best practices (proper HTTP verbs, status codes, etc.)
- Design for scalability and performance
- Include proper error handling and validation
- Consider rate limiting and caching strategies
- Maintain consistency across endpoints
2. Using /agents Command
- Run
kodeto start the REPL - Type
/agents - Press
cto create - Follow the prompts:
- Enter agent name
- Describe when to use it
- Specify allowed tools
- Optionally specify a model
- Write the system prompt
Advanced Usage
Tool Restrictions
tools: ["FileRead", "Grep", "Glob"] # Specific tools
tools: ["*"] # All tools (default)
Model Selection
Specify which AI model the agent should use:
model_name: quick # Fast responses for simple tasks
model_name: main # Default model for general tasks
model_name: reasoning # Complex analysis and design
Available Built-in Agents
general-purpose
- Use for: General research, complex multi-step tasks
- Tools: All tools
- Model: task (default)
Note: This is currently the only built-in agent. Create custom agents using the /agents command or by adding configuration files.
Custom Agents
Create your own agents in the appropriate directory:
mkdir -p .kode/agents # Project-specific
mkdir -p ~/.kode/agents # User-wide
Best Practices
-
Agent Naming: Use descriptive, action-oriented names (e.g.,
test-writer,api-designer) -
Tool Selection: Only include tools the agent actually needs
-
System Prompts: Be specific about the agent's role and guidelines
-
Model Choice:
- Use
quickfor simple, fast operations - Use
mainfor general coding tasks - Use
reasoningfor complex analysis
- Use
-
Organization:
- Keep user agents for personal workflows
- Keep project agents for team-shared configurations
Troubleshooting
Agents not loading?
- Check file permissions in
~/.kode/agents/or./.kode/agents/ - Ensure YAML frontmatter is valid
- Use
/agentscommand and pressrto reload
Agent not working as expected?
- Verify the tools list includes necessary tools
- Check the system prompt is clear and specific
- Test with verbose mode to see actual prompts
Hot reload not working?
- File watcher requires proper file system events
- Try manual reload with
/agentsthenr - Restart Kode if needed
Integration with Task Tool
The agent system is integrated with Kode's Task tool:
// In your code or scripts
await TaskTool.call({
description: "Search for patterns",
prompt: "Find all instances of TODO comments",
subagent_type: "general-purpose"
})
This allows programmatic use of agents in automation and scripts.
Future Enhancements
Planned improvements:
- Agent templates and inheritance
- Performance metrics per agent
- Agent composition (agents using other agents)
- Cloud-based agent sharing
- Agent versioning and rollback