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

# Routing and Orchestration Patterns

> Choose how Duckie sends work to the right agent, workflow, or human review path

Routing decides what starts a run and who should handle it. Orchestration decides what happens after the run starts.

A simple mental model:

* **Deployments** bring work in.
* **Agents** handle or delegate.
* **Workflows** control known steps.
* **Runbooks** guide flexible procedures.
* **Guardrails** route risky situations to humans.
* **Runs** show what happened.

## Pattern 1: Route at the Deployment

Use deployment routing when the channel, event, group, tag, webhook, or schedule already tells Duckie what should happen.

Examples:

* Zendesk new ticket in a billing group starts a Billing Agent.
* Slack mention in a support channel starts a Support Agent.
* A custom webhook from an internal system starts an intake workflow.
* A scheduler starts a reporting agent every weekday morning.

This keeps the entry point simple and makes ownership clear before the run begins.

## Pattern 2: Use a Workflow Backbone

Use workflows for repeatable routing, required checks, approvals, retries, and exact tool order.

Keep known process state in the workflow. Call agents only where judgment, language, research, or specialist review is needed.

Examples:

* Refund eligibility: look up order, check policy, respond or escalate.
* Case intake: validate required fields, classify, route missing data to enrichment.
* Sensitive account update: verify the account, branch to approval, then update.

## Pattern 3: Let an Autonomous Agent Choose the Path

Use autonomous agents when requests vary and Duckie needs to choose knowledge, runbooks, workflows, tools, or sub-agents.

This works well for broad support, triage, research-heavy questions, and multi-topic conversations. Keep the agent's scope clear with Tools, Knowledge Tags, Runbooks & Workflows, and Callable agents.

## Pattern 4: Delegate to Specialist Agents

Use sub-agents for focused expertise, safer tool access, or clean handoffs.

The parent workflow or agent keeps ownership of the customer experience. The child agent handles a narrower task and returns a useful result.

Examples:

* General Support Agent delegates a billing question to Billing Agent.
* Workflow calls Evidence Drafting Agent, then routes the output to approval.

## Pattern 5: Keep Humans in the Loop

Use Escalation Rules, Restrictions, the Escalator tool, and approval settings when the situation needs human judgment.

Common triggers include legal threats, account security, VIP handling, high-value refunds, angry customers, low confidence, and requests outside policy.

## Pattern 6: Run Recurring Operational Work

Use scheduled deployments for daily summaries, SLA checks, periodic reviews, and feedback loops.

Duckie Assistant agents fit well for reporting, run review, and Duckie configuration improvement. They are not usually the primary choice for real-time customer support routing.

## Choosing the Pattern

| Use this           | When                                                     |
| ------------------ | -------------------------------------------------------- |
| Deployment routing | Source, event, filter, or schedule is enough             |
| Workflow           | Steps must happen predictably                            |
| Autonomous agent   | Judgment, research, or flexible sequencing matters       |
| Runbook            | A procedure is structured but still conversational       |
| Sub-agent          | One part of the job needs a specialist                   |
| Human review       | Risk, policy, confidence, or authority requires approval |

## Test and Monitor

Start deployments in **Testing** mode when possible. Use **Test > Playground**, **Test > Replay Chats**, and **Test > Batch Test** before switching to **Live**.

After launch, review **Analyze > Runs** and track Categories, Attributes, and Resolution Tracking so you can see which routes are working.

## Related Docs

<CardGroup cols={2}>
  <Card title="Deployments" icon="rocket" href="/deployments/overview">
    Connect agents and workflows to channels, events, webhooks, and schedules.
  </Card>

  <Card title="Workflows" icon="diagram-project" href="/workflows/overview">
    Build deterministic routing and process logic.
  </Card>

  <Card title="Autonomous Agents" icon="wand-magic-sparkles" href="/agents/autonomous-agents">
    Let agents choose resources and tools at run time.
  </Card>

  <Card title="Guardrails" icon="shield" href="/guardrails/overview">
    Route risky situations to escalation or restriction paths.
  </Card>
</CardGroup>
