Agents
Codebuff uses specialized AI agents to break down complex coding tasks into manageable pieces. Each agent is optimized for a specific purpose, using the right model and tools for the job.What is an Agent?
An agent is a self-contained AI worker that:- Has a specific purpose (e.g., finding files, editing code)
- Uses a selected AI model optimized for its task
- Has access to specific tools (read files, search code, etc.)
- Can spawn other agents to delegate subtasks
- Follows custom prompts tailored to its role
agents/ directory and follow the AgentDefinition interface from agents/types/agent-definition.ts.
Built-in Agents
Base Agent (base2)
Purpose: The main orchestrator that coordinates all other agents to complete user requests. Location:agents/base2/base2.ts
Model: claude-opus-4.6 (or minimax-m2.5 in free mode)
Key capabilities:
- Plans and breaks down user requests
- Spawns specialized agents in parallel
- Manages context and coordinates workflow
- Validates and reviews changes
- Runs tests and verification commands
spawn_agents- Delegate to specialized agentsread_files- Read file contentsread_subtree- Read entire directory treeswrite_todos- Track task progressstr_replace- Make precise code editswrite_file- Create or overwrite filespropose_str_replace/propose_write_file- Propose changesask_user- Request clarification from userskill- Load specialized workflowsset_output- Return structured output
base2.ts):
The base agent has different modes: DEFAULT, MAX, FAST, and FREE - each optimized for different use cases.
File Picker (file-picker)
Purpose: Find relevant files in the codebase related to a user’s request. Location:agents/file-explorer/file-picker.ts
Display Name: “Fletcher the File Fetcher”
Model: google/gemini-2.5-flash-lite (fast and cost-effective)
How it works:
- Spawns a
file-listeragent with the user’s prompt - File-lister returns paths to potentially relevant files
- Automatically reads the discovered files
- Returns a concise analysis with file paths and summaries
- Finding files related to a feature or bug
- Discovering architecture patterns
- Locating dependencies or imports
Code Searcher (code-searcher)
Purpose: Search for specific code patterns, function names, or text across the codebase. Location:agents/file-explorer/code-searcher.ts
Model: google/gemini-3.1-flash-lite-preview
Tool used: code_search (uses ripgrep under the hood)
What it searches:
- All project files (respects .gitignore)
- Hidden directories:
.agents,.claude,.github,.gitlab,.circleci,.husky
- Finding where a function is used
- Searching for TODO comments
- Finding error messages
- Locating specific patterns or imports
Directory Lister (directory-lister)
Purpose: List files in specific directories to understand structure. Location:agents/file-explorer/directory-lister.ts
Model: google/gemini-3.1-flash-lite-preview
Tool used: list_directory
When to use:
- Exploring project structure
- Understanding directory organization
- Finding what files exist in a specific location
Commander (commander)
Purpose: Execute terminal commands and analyze their output. Location:agents/commander.ts
Model: google/gemini-3.1-flash-lite-preview
Tool used: run_terminal_command
Key features:
- Runs single terminal command
- Analyzes output based on what’s requested
- Can return raw output or LLM summary
- Configurable timeout (default 30s, set to -1 for infinite)
- Running tests (
npm test,pytest) - Type checking (
tsc --noEmit) - Linting (
eslint .) - Git operations (
git status,git diff) - Build commands (
npm run build)
Editor (editor)
Purpose: Implement code changes based on context and requirements. Location:agents/editor/editor.ts
Display Name: “Code Editor”
Model: claude-opus-4.6 (or gpt-5.1 variant)
Tools: write_file, str_replace, set_output
Output mode: structured_output (returns all messages)
Inherits parent context: includeMessageHistory: true
How it works:
- Receives full conversation context
- Uses
<think>tags to plan implementation - Makes file changes using tool calls
- Returns all changes as structured output
editor.ts):
- Implementing features after context is gathered
- Making precise code changes
- Refactoring code
- Fixing bugs
Code Reviewer (code-reviewer)
Purpose: Review and validate code changes for correctness and quality. Location:agents/reviewer/code-reviewer.ts
Model: Varies by mode (Opus 4.6 for default)
When to use:
- After implementing changes
- To catch potential bugs
- To ensure code quality
- To validate against requirements
- Reviews all file changes made
- Checks for logic errors, edge cases
- Validates against coding standards
- Suggests improvements
Context Pruner (context-pruner)
Purpose: Automatically manage conversation context to stay within token limits. Location:agents/context-pruner.ts
Model: gpt-5-mini (efficient for summarization)
Display Name: “Context Pruner”
How it works:
- Runs automatically between steps (never manually spawned)
- Checks if context exceeds
maxContextLength(default 200k tokens) - Summarizes conversation if needed:
- Preserves user messages
- Summarizes tool calls and results
- Keeps error messages and important info
- Removes
<think>tags to save tokens
- Compresses to ~10% of max context
context-pruner.ts):
- file-picker
- code-searcher
- directory-lister
- glob-matcher
- researcher-web
- researcher-docs
- commander
- code-reviewer
You never need to spawn context-pruner yourself - it runs automatically when needed.
Thinker (thinker)
Purpose: Handle complex reasoning and problem-solving. Location:agents/thinker/
When to use:
- Complex architectural decisions
- Algorithm design
- Debugging tricky issues
- Planning multi-step refactors
Researcher Agents
researcher-web: Search the web for documentation and solutions researcher-docs: Search specific documentation sites When to use:- Learning about unfamiliar libraries
- Finding API documentation
- Checking best practices
- Looking up error messages
Glob Matcher (glob-matcher)
Purpose: Find files matching glob patterns. Tool used:glob (uses micromatch)
When to use:
- Finding all files of a certain type (
**/*.test.ts) - Matching specific patterns
- Bulk file operations
Agent Lifecycle
Every agent follows this lifecycle:- Spawn: Parent agent spawns with prompt and params
- Initialize: Agent receives context (messages, system prompt, tools)
- Execute:
handleStepsgenerator runs - Tool Calls: Agent uses tools to accomplish tasks
- LLM Steps: Agent sends messages to LLM for reasoning
- Complete: Agent returns output to parent
Agent Modes
The base agent has different operational modes:DEFAULT Mode
- Balanced quality and speed
- Spawns editor, code-reviewer, thinker
- Uses Claude Opus 4.6
- Includes todos and followup suggestions
MAX Mode
- Maximum quality and thoroughness
- Spawns editor-multi-prompt (multiple implementation proposals)
- Spawns code-reviewer-multi-prompt
- Reads more files for context (12-20 files)
- Uses Claude Opus 4.6
- Higher credit usage
FAST Mode
- Speed prioritized
- Base agent does edits directly (no editor agent)
- Minimal validation
- Extremely concise responses
- Lower credit usage
FREE Mode
- Uses free/cheaper models
- Minimax M2.5 for base agent
- Commander-lite, editor-lite, code-reviewer-lite
- Good for simple tasks
Best Practices
Let Agents Delegate
Don’t try to do everything in one agent. Let the base agent spawn specialists:Spawn in Parallel
When tasks are independent, spawn agents in parallel:Gather Context First
Always gather context before making changes:Use the Right Model
Fast agents for routine tasks, powerful models for complex reasoning:- File discovery: Gemini Flash
- Commands: Gemini Flash Lite
- Editing: Claude Opus or GPT-5
- Reasoning: Claude Opus or GPT-5
Creating Custom Agents
See Creating Agents for a full guide. Basic structure:Next Steps
Multi-Agent Orchestration
Learn how agents coordinate
Tools
Explore agent tools
Creating Agents
Build your own agents
Architecture
Understand the system design

