Pattern B: Agent as Workflow Trigger

The agent operates as a smart ingestion layer. It receives unstructured input, reasons about it, and routes the request into one downstream workflow. Its job is to make the routing decision, pass the right input, and finish once that one downstream path has been launched and observed.

flowchart LR Input["Unstructured Input<br/>(email, document, webhook)"] --> Agent["ReAct Agent<br/><i>classify > extract > route</i>"] Agent -->|"invoice detected"| W1["Invoice Processing<br/>Workflow"] Agent -->|"support request"| W2["Support Ticket<br/>Workflow"] Agent -->|"vendor inquiry"| W3["Vendor Onboarding<br/>Workflow"] style Agent fill:#f3e8ff,stroke:#9333ea

When to Use

  • input arrives in unstructured form, such as emails, documents, or free-text webhooks
  • you do not know upfront which workflow should run
  • the agent needs to classify, extract fields, and route once
  • the agent is a router, not a coordinator. It does not keep chaining across multiple workflows

Pattern B vs Pattern C

Pattern B = the agent figures out which workflow to run, routes into that one workflow, and stops there.

Pattern C = the agent coordinates multiple workflows, reasons over their results, and decides what to do next.

If your agent makes one routing decision and hands off to one downstream path, that is Pattern B. If it keeps coordinating across several downstream steps, that is Pattern C.

---

How It Differs From Pattern C

Pattern B: Trigger Pattern C: Orchestrator
Workflow calls One downstream workflow Multiple workflows
Decision complexity One classification and routing decision Multi-step coordination and synthesis
Agent's role Intelligent router Decision-maker and coordinator
After the workflow call Agent completes Agent continues reasoning
Typical iterations 3-5 10-20

Tool Declaration

Pattern B agents need classification actions and workflow targets declared as typed tools:

json
{
  "tools": [
    { "type": "action", "name": "classify_document" },
    { "type": "action", "name": "extract_fields" },
    { "type": "workflow", "id": "wfl-invoice-processing-001", "description": "Process and reconcile invoices against POs" },
    { "type": "workflow", "id": "wfl-support-triage-002", "description": "Triage and respond to support tickets" },
    { "type": "workflow", "id": "wfl-vendor-onboarding-003", "description": "Onboard new vendors with verification" }
  ]
}

The engine resolves these in two batched queries — one for actions and one for workflows. Workflow tools are referenced by ID, but the model sees the stored workflow names and descriptions when it chooses where to route the request. Implicit tools such as __complete__ and __pause_for_human__ are auto-injected by the runtime.


Complete Example: Document Classifier and Router

Agent Configuration

json
{
  "objective": "Review the following inbound document excerpt and route it to exactly one downstream workflow. First classify the document. Then extract the minimum fields needed by the chosen workflow. Trigger that workflow, then complete.

Document excerpt:
Invoice #INV-2026-0891 from Acme Supplies for $4,250.00 due 2026-03-15.",
  "tools": [
    { "type": "action", "name": "classify_document" },
    { "type": "action", "name": "extract_fields" },
    { "type": "workflow", "id": "wfl-invoice-processing-001", "description": "Process invoices — match to POs, flag exceptions, route for approval" },
    { "type": "workflow", "id": "wfl-support-triage-002", "description": "Handle support requests — triage, investigate, respond" },
    { "type": "workflow", "id": "wfl-vendor-onboarding-003", "description": "Vendor onboarding — verify business, set up account" }
  ],
  "config": {
    "model": "gpt-4",
    "max_iterations": 8,
    "on_stuck": { "iterations": 3, "action": "escalate" }
  }
}

Execute via Standalone Agent API

bash
curl -X POST https://your-hyphen.example.com/agents/execute   -H "X-Org-Id: acme-corp"   -H "Content-Type: application/json"   -d '{
    "objective": "Review the following inbound document excerpt and route it to exactly one downstream workflow. First classify the document. Then extract the minimum fields needed by the chosen workflow. Trigger that workflow, then complete.

Document excerpt:
Invoice #INV-2026-0891 from Acme Supplies for $4,250.00 due 2026-03-15.",
    "tools": [
      { "type": "action", "name": "classify_document" },
      { "type": "action", "name": "extract_fields" },
      { "type": "workflow", "id": "wfl-invoice-processing-001" },
      { "type": "workflow", "id": "wfl-support-triage-002" },
      { "type": "workflow", "id": "wfl-vendor-onboarding-003" }
    ],
    "config": { "model": "gpt-4o", "max_iterations": 8 }
  }'

Today, the standalone agent API takes the objective directly. For Pattern B, that usually means putting the relevant email or document excerpt into the objective, or wrapping the agent in a workflow if you need richer structured context.

---

Sample Reasoning Trace

text
Iteration 1:
  Thought: "I should classify the document before choosing a workflow."
  Action: classify_document
  Input: { "text": "Invoice #INV-2026-0891 from Acme Supplies for $4,250.00 due 2026-03-15." }
  Observation: { "category": "invoice", "confidence": 0.97 }

Iteration 2:
  Thought: "It is an invoice with high confidence. I will extract the fields the invoice workflow needs."
  Action: extract_fields
  Input: {
    "text": "Invoice #INV-2026-0891 from Acme Supplies for $4,250.00 due 2026-03-15.",
    "document_type": "invoice"
  }
  Observation: {
    "invoice_number": "INV-2026-0891",
    "vendor": "Acme Supplies",
    "amount": 4250.00,
    "due_date": "2026-03-15"
  }

Iteration 3:
  Thought: "Classification and extraction are done. I will route this into the invoice workflow."
  Action: invoice_processing
  Input: {
    "invoices": [{
      "invoice_number": "INV-2026-0891",
      "vendor": "Acme Supplies",
      "amount": 4250.00,
      "due_date": "2026-03-15"
    }],
    "source": "email_ingestion"
  }
  Observation: {
    "workflow_run_id": "run-123e4567-e89b-12d3-a456-426614174000",
    "status": "completed"
  }

Iteration 4:
  Thought: "The downstream workflow ran and returned. My routing task is complete."
  Action: __complete__
  Input: {
    "answer": "Document classified as invoice and routed to the invoice_processing workflow.",
    "confidence": 0.97
  }

Key Properties

  • One downstream workflow call — the agent chooses one destination and does not continue coordinating across several workflows
  • Typed workflow tools — the routing menu is explicit and org-scoped
  • Standalone execution — this agent runs via POST /agents/execute, not inside a workflow. It is the entry point
  • Short iteration budgetmax_iterations: 8 is usually enough for classify → extract → route → complete

Scaling the Pattern

For high-volume ingestion, keep each Pattern B run independent:

  • enqueue one standalone agent execution per document or email
  • let each agent classify, route, and complete on its own
  • keep downstream processing in the triggered workflow, not in the router agent

Avoid trying to nest a ReAct loop inside another loop step. Nested loops are not supported by the workflow validator.


Anti-Pattern: When Pattern B Becomes Pattern C

If you find yourself writing an objective like this, you have outgrown Pattern B:

text
"Classify this document, trigger the right workflow, wait for the result,
and if it fails, try a different workflow, then send a summary email."

The moment your agent needs to wait for a result and make a new workflow decision based on it, you are in Pattern C territory.

Next: Pattern C: Agent as Orchestrator