> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mixus.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Micro-Agent Concepts & Architecture

> Deep dive into micro-agent concepts, chaining patterns, and technical implementation details

## Definition

A **micro-agent** is a highly focused AI agent with 1-3 steps designed to accomplish a single, well-defined task. Unlike traditional monolithic agents that try to handle entire workflows, micro-agents embrace the Unix philosophy: "do one thing and do it well."

## Core Architecture

```
Traditional Agent (Monolithic):
┌─────────────────────────────────┐
│  Research + Analyze + Report    │  ← 10-15 steps, complex logic
│  (All in one agent)             │  ← High context usage
└─────────────────────────────────┘

Micro-Agent Chain:
┌─────────┐     ┌─────────┐     ┌─────────┐
│Research │ --> │ Analyze │ --> │ Report  │  ← 2-3 steps each
│ Agent   │     │ Agent   │     │ Agent   │  ← Focused context
└─────────┘     └─────────┘     └─────────┘
```

## How chaining actually works

### 1. Agent creation phase

```typescript theme={null}
// Agent 1: Data Collector
{
  name: "daily-sales-collector",
  steps: [
    {
      description: "Connect to Salesforce and pull today's sales data",
      requiresVerification: false
    },
    {
      description: "Format data into structured JSON with key metrics",
      requiresVerification: false
    },
    {
      description: "Run the 'sales-analyzer' agent with the formatted data",
      requiresVerification: false
    }
  ]
}
```

### 2. Runtime execution

* Step 1 & 2 execute normally using available tools
* Step 3 triggers `findAndRunAgent` tool internally
* The AI recognizes "Run the X agent" pattern and converts to tool call
* New chat is created for the downstream agent
* Context is passed via the `instructions` parameter

### 3. Context flow

```text theme={null}
Agent 1 Output: {sales: $45K, leads: 23, conversions: 5}
                         ↓
Agent 2 receives this as initial context
                         ↓
Agent 2 Output: {trend: "up 15%", anomalies: [...]}
                         ↓
Agent 3 receives cumulative insights
```

## Benefits over monolithic agents

| Aspect           | Monolithic          | Micro-Agent Chain    |
| ---------------- | ------------------- | -------------------- |
| Token Usage      | High (full context) | Low (scoped context) |
| Failure Recovery | Restart entire flow | Restart single agent |
| Debugging        | Complex traces      | Isolated logs        |
| Human Review     | Overwhelming        | Focused chunks       |
| Reusability      | Limited             | High (mix & match)   |
| Cost             | Higher              | 40-60% lower         |

## Implementation patterns

### Sequential chain

```text theme={null}
[Extract] → [Transform] → [Load] → [Validate]
```

### Branching chain

```text theme={null}
            ┌→ [Email Report]
[Analyze] ──┤
            └→ [Slack Alert]
```

### Convergent chain

```text theme={null}
[Source A] ─┐
            ├→ [Aggregate] → [Report]
[Source B] ─┘
```

## Technical implementation details

When an agent step contains text like "run the X agent", the system:

1. **Pattern Recognition**: The AI model identifies agent execution intent
2. **Tool Invocation**: Calls `findAndRunAgent` with:
   * `agentName`: Extracted from the step description
   * `instructions`: Output from current agent's execution
   * `addContext`: Set to true to include recent messages
3. **Chat Creation**: New chat is spawned with:
   * Title: "Execution of \[Agent Name] - triggered by \[Parent Agent]"
   * Initial context: Instructions + any passed data
4. **Execution**: Child agent runs in isolation with its own:
   * Token budget
   * Tool access
   * Execution logs
   * Error handling

## Best practices for micro-agent design

1. **Single Responsibility**: Each agent should have ONE clear purpose
2. **Clear Naming**: Use descriptive names like "invoice-validator" not "agent-1"
3. **Explicit Outputs**: Define what data the agent produces
4. **Error Handling**: Include fallback steps for common failures
5. **Idempotency**: Agents should be safe to re-run

## Example: complete sales pipeline

```yaml theme={null}
Micro-Agent 1: lead-scraper
  Step 1: Search LinkedIn for matching prospects
  Step 2: Extract contact information
  Step 3: Run 'lead-enricher' with the contact list

Micro-Agent 2: lead-enricher
  Step 1: Look up company information for each lead
  Step 2: Score leads based on ICP criteria
  Step 3: Run 'outreach-drafter' with qualified leads

Micro-Agent 3: outreach-drafter
  Step 1: Generate personalized email for each lead
  Step 2: Schedule emails in outreach tool
  Step 3: Run 'campaign-tracker' to monitor opens

Micro-Agent 4: campaign-tracker
  Step 1: Check email open/click rates hourly
  Step 2: Flag hot leads for immediate follow-up
  Step 3: Generate daily performance report
```

Each agent is reusable - you could swap 'outreach-drafter' for 'linkedin-messenger' without touching the other agents.

## Related documentation

* [Context Management & Verification](micro-agent-context-verification) - How context flows between agents
* [KPI Monitoring](micro-agent-kpi-monitoring) - Using search-chat-history for performance tracking
* [Multi-User Verification](micro-agent-multi-user-verification) - Distributed approval workflows
* [Advanced Use Cases](micro-agent-use-cases-tips) - Creative applications and optimization tips

***

*Need help implementing micro-agent chains? Check our [agent creation guide](/agents/creating) or contact [support](/support/contact).*
