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 |
|---|---|---|
name | Unique identifier for the agent | Yes |
model | LLM model to use | Yes |
task | Description of the agent’s purpose | No |
tools | List of tools/skills the agent can use | No |
workdir | Working directory for file operations | No |
runtime | Execution environment (process or docker) | No |
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
Agents can spawn sub-agents for complex tasks:agent_spawn tool:
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.

