What is an Agent?
An agent is the fundamental unit of deployment in klaw. It’s an autonomous AI entity that can:- Understand natural language instructions
- Make decisions about how to accomplish tasks
- Use tools to interact with systems and data
- Maintain conversation context
- Learn from interactions through memory
Agent Architecture
Creating Agents
Using the CLI
Agent Definition File
Agents are stored as TOML files in~/.klaw/agents/:
Agent Lifecycle
Activation
When a message arrives for the agent, it’s activated with its LLM provider, tools, and system prompt.
Agent Properties
| Property | Description | Required | Default |
|---|---|---|---|
name | Unique identifier for the agent | Yes | — |
model | LLM model to use | Yes | — |
task | Description of the agent’s purpose | No | — |
tools | Allowlist of tools the agent can use | No | All tools |
workdir | Working directory for file operations | No | CWD |
runtime | Execution environment (process or docker) | No | process |
max_iterations | Maximum agent loop iterations | No | 50 |
require_approval | Tool names requiring user confirmation | No | [] |
Agent Configuration
Per-agent settings inconfig.toml let you customize tool access, iteration limits, and approval requirements for each agent independently:
tools is omitted, the agent has access to all registered tools. When specified, only the listed tools are available — the agent cannot call tools outside its allowlist.
Approval gating requires user confirmation before specific tools execute. When a tool in the require_approval list is called, the user sees a prompt and must approve or deny execution.
Managing Agents
List Agents
Describe an Agent
Delete an Agent
Agent Communication
Agents receive work through channels:CLI
Direct interaction via
klaw chatSlack
Messages in Slack channels/threads
API
REST API calls for programmatic access
Tasks
Dispatched tasks from controller
Multi-Agent Patterns
Specialized Agents
Create agents for specific domains:Agent Spawning
klaw supports two forms of sub-agent creation:agent_spawn — Creates persistent agent bindings for the orchestrator. These are long-lived agents that can be routed to via @agent syntax.
delegate — Spawns ephemeral sub-agents inline during a conversation. The sub-agent executes immediately, and its result is returned directly to the parent. This is the primary mechanism for multi-step task decomposition.
delegate tool for inline sub-agents:
agent_spawn for persistent bindings:
Agent Runtime Modes
- Process (Default)
- Docker
Agent runs as a local process with direct system access:
- Full filesystem access
- Direct command execution
- Fastest performance
Best Practices
Define clear purposes
Define clear purposes
Give each agent a specific, well-defined task. Specialized agents perform better than generalists.Good: “API development and testing”
Bad: “Do everything”
Minimize tool permissions
Minimize tool permissions
Only give agents the tools they actually need. Avoid granting bash access unless necessary.
Set appropriate workdirs
Set appropriate workdirs
Constrain agents to specific directories to prevent unintended file modifications.
Use appropriate models
Use appropriate models
Match model capabilities to task complexity. Use Sonnet for most tasks, Opus for complex reasoning.
Set cost budgets
Set cost budgets
Use
max_session_cost to cap spending per session. Start conservative (e.g., $5.00) and adjust based on your workload. The agent stops gracefully when the budget is reached.Require approval for risky tools
Require approval for risky tools
Add
require_approval = ["bash", "write"] to agents that modify files or run commands. This adds a human-in-the-loop check before execution.Next Steps
Tools
Learn about the tools agents can use
Skills
Compose capabilities with skills

