Agents and Workflows
Architecture and Runtime Selection
Exam objective: Evaluating whether a workflow or an agentic architecture fits a set of business requirements, error tolerance, and audit constraints. This includes choosing the orchestrator and subagent decomposition and selecting the execution environment: a self-hosted harness or a managed, sandboxed agent runtime.
What the exam tests
Whether you can turn business requirements, error tolerance and audit constraints into an architecture: single call, workflow or agent; how to split work between an orchestrator and subagents; and where the agent runs (your own harness or a managed, sandboxed runtime).
Key rules
- Start simple. Add complexity only when it demonstrably improves outcomes. One call with retrieval and examples is often enough.
- Workflow = predefined code paths: predictable and consistent. Agent = the model directs its own steps: flexible, but costlier, with compounding errors. Give agents sandbox testing, guardrails and stopping conditions.
- Patterns: prompt chaining (fixed steps, programmatic gates), routing (distinct categories), parallelization (independent sections, or voting), orchestrator-workers (subtasks unknown until runtime), evaluator-optimizer (clear criteria, useful feedback loop).
- Multi-agent pays off for valuable, parallel, breadth-first work that exceeds one context window. It uses far more tokens and fits poorly when agents need shared context or depend heavily on each other.
- Delegation: give each subagent an objective, output format, tool and source guidance, and boundaries. Scale effort to complexity. Large outputs can go to external storage, with only references returned.
- Reliability: resume from checkpoints instead of restarting, retry deterministically, and trace production runs.
- Runtime choice:
| Option | Who runs the loop | Where tools run |
|---|---|---|
| Messages API | your code | your code |
| Agent SDK | your process (spawns a claude subprocess) | your host or container |
| Managed Agents | Anthropic | Anthropic cloud sandbox |
| Managed Agents + self-hosted sandboxes | Anthropic | your infrastructure |
| Self-hosted Managed Agents | your server and database | your sandboxes |
- Self-hosting the SDK: transcripts, memory files and artifacts sit on local disk. Use a
SessionStorefor transcripts (it does not cover other files), bound runs withmaxTurns, and isolate tenants. - Controls: SDK hooks block (
PreToolUse) or log (PostToolUse) in code. In Managed Agents,always_askpauses a server-executed tool for approval.
// Tenant isolation in a shared container
query({ prompt, options: {
cwd: tenantDir,
settingSources: [],
maxTurns: 20,
env: { ...process.env, CLAUDE_CONFIG_DIR: configDir,
CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1" },
}});
Traps
- Picking an agent because the task sounds complex, when its steps are fixed.
- Confusing parallelization (subtasks known in advance) with orchestrator-workers (decided per input).
- Treating a system prompt rule as an enforcement or audit control.
- Treating
autoas human review: calls judged safe run unseen. - Assuming self-hosted sandboxes keep session history in house. Only self-hosted Managed Agents does.
- Assuming hosted Managed Agents qualifies for ZDR or a HIPAA BAA. It is stateful and does not.
- Inline Managed Agents subagents use the lead's tools and MCP servers.
SessionStoremirroring is best-effort: a failed batch is dropped with amirror_errormessage.
Decide quickly
| Situation | Choice | Why |
|---|---|---|
| Same steps every time, checkpoint required | Prompt chain with gates | Enforced order |
| Distinct, classifiable request types | Routing | Specialized prompts |
| Files or subtasks unknown in advance | Orchestrator-workers | Dynamic decomposition |
| Open-ended path, trusted sandbox | Agent | Model-driven control |
| Long async work, minimal infrastructure | Managed Agents | Loop and sandbox provided |
| Only execution must stay inside your network | Self-hosted sandboxes | Anthropic still runs the service |
| History storage or inference provider must be yours | Self-hosted Managed Agents | You host the service |
| Claude Code capabilities inside your own process | Agent SDK | You operate the harness |