Skip to main content

Overview

Complex tasks often require different expertise. klaw supports multi-agent workflows where specialized agents collaborate, each contributing their unique capabilities. This guide covers patterns for effective multi-agent orchestration.

Why Multi-Agent?

Single agents work well for focused tasks. But consider:

Orchestrator Routing

The simplest multi-agent pattern uses the orchestrator to route messages:

Configure Orchestrator

Automatic Routing

Messages are automatically routed:

Manual Routing

Override with @agent syntax:

Inline Delegation

The delegate tool lets a main agent spawn ephemeral sub-agents that execute immediately and return results. This is the primary mechanism for task decomposition within a single conversation.

Using the delegate Tool

Key properties:
  • Sub-agents run inline — the main agent waits for the result
  • Each sub-agent gets its own tool set (configurable via allowlist)
  • Sub-agents can nest up to 3 levels deep
  • 5-minute timeout per delegation
  • Output truncated at 30,000 characters

In Practice

Persistent Agent Spawning

For long-lived agents that persist across conversations, use agent_spawn to create orchestrator bindings:
Use agent_spawn when you need agents that are routable via @agent syntax and persist beyond a single conversation. Use delegate when you need inline task execution within a conversation.

Workflow Patterns

Sequential Pipeline

Each agent’s output feeds the next:

Parallel Execution

Independent tasks run simultaneously. With the delegate tool, the LLM can issue multiple delegations in a single turn and they execute in parallel:
Via inline delegation:
Or in Slack with orchestrator routing:

Supervisor Pattern

A coordinator agent manages workers:

Creating Specialized Teams

Development Team

Research Team

DevOps Team

Namespace-Based Teams

Organize agents into namespaces for isolation:
Dispatch to namespace:

Communication Patterns

Shared Context via Workspace

Agents share knowledge through workspace files:

Message Passing (Slack)

In Slack, agents can communicate via channels:

Task Dependencies

Use cron or dispatch with dependencies:

Best Practices

Each agent should have a specific, non-overlapping responsibility. Avoid agents that do “everything.”
Define how agents share information—workspace files, specific channels, or structured handoffs.
When one agent finishes, another should verify the output before continuing.
Track which patterns work well. Some tasks may be better with fewer, more capable agents.

Example: Full Feature Development

1. Create the Team

2. Configure Orchestrator

3. Execute the Workflow

Next Steps

Orchestrator

Deep dive into routing

Distributed Deployment

Scale multi-agent systems