Pattern C: Agent as Orchestrator
The agent coordinates multiple workflows, making decisions about what to trigger, in what order, and how to synthesize results across them. The agent is the decision-maker; each workflow is a capability it can invoke.
When to Use
- The process requires dynamic coordination across multiple sub-processes
- The sequence of steps depends on intermediate results
- You need to synthesize information from multiple workflows before deciding the next step
- The agent is the decision-maker, not just a participant
Complete Example: Customer Onboarding
An orchestrator agent that onboards a business customer ā running identity verification, sanctions screening, and conditionally triggering enhanced due diligence.
{
"objective": "Onboard business customer: {{input.company_name}}\n\nCustomer details:\n- Company: {{input.company_name}}\n- Country: {{input.country}}\n- Registration: {{input.registration_number}}\n- Contact: {{input.contact_name}} ({{input.contact_email}})\n\nProcess:\n1. Run identity verification\n2. Run sanctions screening\n3. If any concerns, run enhanced due diligence\n4. If still uncertain, request human review\n5. If approved, provision the account\n6. Send welcome email",
"tools": [
{ "type": "workflow", "name": "identity_verification" },
{ "type": "workflow", "name": "sanctions_screening" },
{ "type": "workflow", "name": "enhanced_due_diligence" },
{ "type": "workflow", "name": "account_provisioning" },
{ "type": "action", "name": "gmail_send" }
],
"config": {
"model": "gpt-4",
"max_iterations": 20,
"timeout_ms": 600000,
"on_stuck": { "iterations": 3, "action": "escalate" }
}
}
Sample Reasoning Trace
Iteration 1:
Thought: "Starting onboarding for Acme GmbH. First step is identity verification."
Action: __log_progress__
Input: { "message": "Starting onboarding", "milestone": "begin" }
Iteration 2:
Thought: "Let me run the identity verification workflow."
Action: __run_workflow__
Input: {
"workflow_name": "identity_verification",
"input": {
"company_name": "Acme GmbH",
"country": "DE",
"registration_number": "HRB 12345"
},
"wait": true, "timeout_ms": 120000
}
Observation: {
"status": "completed",
"result": { "verified": true, "confidence": 0.92, "source": "trade_register" }
}
Iteration 3:
Thought: "Identity verified. Now I need to run sanctions screening."
Action: __store_memory__
Input: { "key": "kyc_result", "value": { "verified": true, "confidence": 0.92 } }
Iteration 4:
Thought: "Running sanctions screening."
Action: __run_workflow__
Input: {
"workflow_name": "sanctions_screening",
"input": {
"entity_name": "Acme GmbH",
"country": "DE",
"registration_number": "HRB 12345"
},
"wait": true
}
Observation: {
"status": "completed",
"result": { "matches_found": 1, "match_type": "partial_name", "risk_level": "medium" }
}
Iteration 5:
Thought: "Sanctions screening found a partial name match with medium risk. This
needs enhanced due diligence before I can proceed."
Action: __log_progress__
Input: { "message": "Partial sanctions match ā triggering EDD", "milestone": "edd_required" }
Iteration 6:
Thought: "Running enhanced due diligence workflow."
Action: __run_workflow__
Input: {
"workflow_name": "enhanced_due_diligence",
"input": {
"entity_name": "Acme GmbH",
"country": "DE",
"sanctions_match": { "match_type": "partial_name", "risk_level": "medium" }
},
"wait": true, "timeout_ms": 180000
}
Observation: {
"status": "completed",
"result": {
"conclusion": "false_positive",
"confidence": 0.78,
"reasoning": "Name similarity to sanctioned entity 'Acme Holdings Ltd' but different jurisdiction and industry."
}
}
Iteration 7:
Thought: "EDD concluded false positive but confidence is only 78%. Since this is
below 85%, I should get human confirmation before provisioning."
Action: __pause_for_human__
Input: {
"question": "EDD concluded false positive (78% confidence) for Acme GmbH sanctions match. Should I proceed with account provisioning?",
"options": ["Approve ā proceed with onboarding", "Reject ā deny application", "Request additional documentation"],
"context_summary": "KYC verified (92%), sanctions partial match on name, EDD says false positive (78%)",
"urgency": "medium"
}
ā Agent pauses. Human reviews and responds: "Approve ā proceed with onboarding" ā
Iteration 8:
Thought: "Human approved. Let me provision the account."
Action: __run_workflow__
Input: {
"workflow_name": "account_provisioning",
"input": {
"company_name": "Acme GmbH",
"country": "DE",
"contact_email": "[email protected]",
"approved_by": "human_review"
},
"wait": true
}
Observation: { "status": "completed", "result": { "account_id": "acc_xyz789" } }
Iteration 9:
Thought: "Account provisioned. Sending welcome email."
Action: gmail_send
Input: {
"__oauth_account__": "[email protected]",
"to": "[email protected]",
"subject": "Welcome to Our Platform ā Acme GmbH",
"body": "Dear Hans,\n\nYour account (acc_xyz789) has been provisioned..."
}
Observation: { "sent": true, "message_id": "msg_abc" }
Iteration 10:
Thought: "Onboarding complete. All steps passed."
Action: __complete__
Input: {
"answer": "Onboarding complete for Acme GmbH. KYC verified, sanctions false positive confirmed by human review, account acc_xyz789 provisioned, welcome email sent.",
"confidence": 0.95,
"summary": "4 workflows executed, 1 human review, account provisioned"
}
What Makes This Pattern Powerful
Dynamic sequencing. The agent decided to run EDD because sanctions screening returned a partial match. If screening had returned clean, it would have skipped EDD entirely.
Cross-workflow synthesis. The agent combined results from KYC, sanctions, and EDD to make a holistic decision ā and recognized that 78% confidence was too low to proceed without human confirmation.
Conditional escalation. The agent used a confidence threshold to decide when to involve a human. Clear cases flow through automatically; uncertain cases get human review.
Full audit trail. Every workflow triggered, every result received, every human decision, and the agent's reasoning about all of it ā captured in one trace.
Key Design Considerations
- Set
max_iterationshigher for orchestrator agents (15ā20). They make more tool calls because they coordinate multiple workflows - Set
timeout_msappropriately. Orchestators wait for sub-workflows, so total time is the sum of all sub-workflow durations plus agent reasoning time - Use
__store_memory__to save intermediate results. The agent's context window grows with each iteration, but explicit memory storage makes retrieval reliable - Include
__pause_for_human__as a tool. Orchestrators make high-stakes decisions and should have the option to escalate
ā Back to Deployment Patterns overview