Domain 127% weight

Quick Reference: Domain 1Agentic Architecture & Orchestration

The Agentic Loop

Every agentic system follows the same core loop: receive input, reason, act (tool call), observe results, decide to continue or stop. The loop is governed by stop_reason in the API response.

stop_reasonMeaningLoop Action
end_turnClaude finished voluntarilyExit loop — task complete
tool_useClaude wants to call a toolExecute tool, feed result back, continue
max_tokensOutput limit reachedMay need continuation logic

Key rule: Always set a maximum iteration limit to prevent infinite loops. Feed tool errors back to Claude — it can often self-correct.

Orchestration Patterns

PatternWhen to UseKey Characteristic
Prompt ChainingSequential transformation stepsOutput of step N is input to step N+1
RoutingDifferent input types need different handlingClassification step dispatches to specialists
Parallelization (Fan-Out/Fan-In)Independent subtasksSplit, process concurrently, aggregate
Evaluator-OptimizerIterative quality improvementGenerate, evaluate, refine until threshold met
Orchestrator-WorkerDynamic subtask decompositionCentral agent plans, delegates, synthesizes
Anti-PatternWhy It Fails
Over-orchestrating simple tasksSingle Claude call often sufficient — added latency for no benefit
Sharing mutable state between parallel agentsRace conditions and inconsistent results
No exit condition on loopsInfinite loops burning tokens and time
Routing without a fallbackUnclassified inputs get dropped silently

Guardrails

Three types: input guardrails (validate before Claude sees it), output guardrails (validate Claude's response before returning to user), tool-use guardrails (restrict which tools and parameters are allowed).

In the Agent SDK: guardrails run as parallel checks alongside the main agent. They can halt execution immediately if a violation is detected.

Claude Agent SDK Primitives

PrimitivePurpose
AgentDefines system prompt, tools, guardrails, and handoff targets
Runner.run()Manages the agentic loop internally
@tool decoratorRegisters a function as a tool with auto-generated schema
@guardrail decoratorRegisters input/output validation functions
HandoffTransfers control from one agent to another

Multi-Agent vs Single-Agent Decision

Use single agent when: one tool set covers the task, shared context is critical, latency matters.

Use multi-agent when: tasks need fundamentally different tool sets, domain expertise varies, you need isolation between concerns.