Agentic Loops: Worked Example — Agentic Architecture & Orchestration (Claude Certified Architect)
Agentic Loops Worked Example: Designing an Autonomous Task Execution System In this worked example, we will design and implement an agentic loop...
Agentic Loops Worked Example: Designing an Autonomous Task Execution System
In this worked example, we will design and implement an agentic loop using the Claude Agent SDK to autonomously manage a customer support ticket triage workflow. This scenario demonstrates key concepts in agentic architecture such as task decomposition, multi-agent orchestration, context passing, and session state management.
Scenario Overview
A company receives customer support tickets that must be categorized, prioritized, and assigned to the appropriate team. The goal is to automate this process with an agentic loop that autonomously executes the triage workflow, coordinating multiple subagents for classification, priority scoring, and assignment recommendation.
Step 1: Define the Agentic Loop and Task Decomposition
We begin by decomposing the overall triage task into three sub-tasks:
- Classification: Determine the ticket category (e.g., billing, technical, general inquiry).
- Priority Scoring: Assign a priority level based on urgency and impact.
- Assignment Recommendation: Suggest the best team or agent to handle the ticket.
Each sub-task will be handled by a dedicated subagent within the multi-agent system.
Step 2: Implement the Coordinator Agent
The coordinator agent orchestrates the workflow by spawning subagents and managing context passing. It initiates the loop by receiving a new ticket and passing its details to the classification subagent.
Step 3: Subagent Context Passing and Spawning
Using the Claude Agent SDK, the coordinator spawns the classification subagent with the ticket context. Upon completion, the classification result is passed back to the coordinator, which then spawns the priority scoring subagent with the updated context, including the classification output.
Step 4: Multi-Step Workflow with Programmatic Enforcement
The coordinator enforces the sequence of subagent executions programmatically, ensuring that each step completes successfully before moving to the next. This enforcement guarantees the integrity of the workflow and prevents premature task progression.
Step 5: Applying SDK Hooks for Tool Call Interception
To enhance observability and control, SDK hooks are implemented to intercept tool calls made by subagents. For example, when the classification subagent calls an external knowledge base API, the hook logs the request and response for auditing.
Step 6: Managing Session State Including Resumption and Forking
The agentic loop manages session state to support resumption in case of interruptions. If the process is paused after priority scoring, the coordinator can resume from that point without restarting. Additionally, the system supports forking, allowing parallel exploration of alternative assignment recommendations.
Worked Example: Step-by-Step Implementation
- Receive Ticket: Coordinator agent receives ticket with text "My internet is down since yesterday."
- Spawn Classification Subagent: Pass ticket text to classification subagent.
- Classification Result: Subagent returns category "Technical Issue." Coordinator updates context.
- Spawn Priority Scoring Subagent: Pass updated context to priority scoring subagent.
- Priority Result: Subagent returns priority "High." Coordinator updates context.
- Spawn Assignment Recommendation Subagent: Pass updated context for assignment suggestion.
- Assignment Result: Subagent suggests "Network Support Team." Coordinator finalizes context.
- Complete Loop: Coordinator outputs triage result with category, priority, and assignment.
This stepwise orchestration ensures autonomous, reliable triage processing with clear context flow and state management.
Summary
This worked example illustrates how to design an agentic loop using the Claude Agent SDK for autonomous task execution. By decomposing tasks, orchestrating subagents, managing context and session state, and applying SDK hooks, solution architects can build robust multi-agent systems that handle complex workflows efficiently.
More in this topic
Ready to test your knowledge?
Put what you've learned into practice with a quick quiz and track your progress.
Test your knowledge →