Ads

Lesson 5 – Claude Certified Architect – Full Course

Learn to build a multi-agent system using Claude's raw SDK with agentic loops, coordinator patterns, and structured context passing in a single Python file.

⏱ 12min 👁 7,666 views 📅 April 17, 2026

More from this course

Claude Certified Architect – Full Course

Lesson 5 of 22

Summary

Bridging theory and practice

This episode serves as the practical capstone for the first module of the Claude Certified Architect course, transforming theoretical concepts into a tangible, executable codebase. Previous episodes laid the groundwork by explaining the mechanics of agentic loops driven by stop reasons instead of arbitrary iteration limits, the architecture of coordinator patterns for spawning specialized sub-agents, and the critical importance of structured context passing with claim-source mappings. Here, all those abstract principles are woven into a single, self-contained Python script. The code is designed to be copied, pasted, and run immediately, requiring no external APIs beyond the standard Anthropic SDK. It acts as a blueprint, demonstrating how to orchestrate multiple Claude instances working together to solve a complex task through delegation and verified information retrieval.

The core objective is to demonstrate a correct implementation pattern for building agents with the raw Anthropic SDK, filling a gap left by tools like Claude Code which handle orchestration internally. By building the scaffolding from scratch, learners gain a deep understanding of how structured outputs, tool-use cycles, and message history management function in a production-oriented context. The included fake knowledge base serves as a stand-in for a vector store or search API, ensuring the focus remains squarely on the agentic architecture rather than infrastructure setup. Every line of the script is dissected, revealing how the system manages state transfer between a coordinator and its sub-agents, how findings are carefully attributed to their sources, and how the loop conditionally continues or terminates based on the model's own reasoning reflected in the stop reason parameter.

The anatomy of an agentic loop

The foundational pattern driving the entire system is the agentic loop, structured around the stop_reason parameter in the API response rather than a brittle, hard-coded number of iterations. A naive loop might simply count steps or iterate blindly until a generic limit is reached, but this approach ignores the model's native signaling mechanisms. The implementation in this lesson listens intently for whether the loop should continue or end based on the stop reason. When the API response indicates a tool call is required, the loop processes it and provides the result back to the model, allowing it to re-evaluate. This creates a true reasoning cycle where the agent maintains agency, deciding autonomously when its task is complete and a final text response should be delivered.

This approach is critical for building reliable, cost-efficient agents. By deferring termination logic to the model's internal assessment, the script avoids unnecessary API calls that waste tokens and time. The demonstration shows how simple Python constructs can manage this conversational turn-taking, tracking the evolving list of messages that constitute the agent's working memory. This model-driven flow control is the skeleton upon which more complex behaviors, such as coordinating multiple agents, are built. It ensures the system remains responsive to context, ending early if the problem is simple or persisting through multiple tool calls when the task demands deeper investigation, all without a programmer guessing at the required number of steps.

Coordination through delegation tools

Moving beyond a single-agent system, the code illustrates the coordinator pattern by defining custom tools that allow a primary agent to spawn and manage sub-agents. The coordinator agent is not merely handling a user query; it is acting as a director that can create new Claude instances, assign them specific research tasks, and synthesize their results. The custom tool definition is the critical interface here. When the coordinator decides an investigation requires a specialized focus, it generates a function call that the Python scaffold intercepts. This trigger then spawns a new agent run, which receives a tightly scoped prompt and specific instructions.

The sub-agent executes its own agentic loop, potentially using tools or processing data, and returns a structured finding back to the coordinator. This pattern solves a fundamental challenge in complex AI systems: context isolation. A single agent with a monolithic prompt would quickly become overwhelmed or confused when juggling multiple complex tasks. By delegating, each sub-agent works within a clean, focused context space, increasing accuracy and reducing hallucination. The code walkthrough meticulously demonstrates how to construct the sub-agent's initial messages and how to capture its final output, mapping it back into the coordinator's message history as if it were a standard tool result, thereby maintaining a seamless logical flow.

Structured context and claim verification

A significant portion of the architectural logic deals with how information is passed between agents to maintain integrity and traceability. The system implements a structured findings format that pairs claims with their explicit sources. When a sub-agent returns information, it does not return raw, unverified text. Instead, it follows a schema that forces it to specify what it found and where the evidence originated. In the demonstration, this is mapped against the internal fake knowledge base, which simulates trusted documents or a curated dataset that the agents are allowed to query. This creates a full chain of custody for every piece of information ingested by the coordinator.

Structured context passing solves the problem of information rot and confabulation in multi-hop agent systems. Without this discipline, a coordinator might blindly trust a sub-agent's summary, which itself might be a hallucination or a misreading of the source. By requiring explicit source mapping, the architecture enables later verification steps and provides the end-user with clear citations. The Python code shows how to enforce this structure using the SDK's capabilities for generating JSON outputs or parsing tool-call arguments. This transforms the multi-agent system from a risky game of telephone into an auditable, reliable pipeline where the origins of every factual assertion can be traced back to the underlying data.

Bridging Claude Code and the raw SDK

A key insight offered by this module is the distinction between the high-level convenience of Claude Code and the granular control of the raw Anthropic SDK. Claude Code abstracts away the complexity of tool orchestration, including the Task tool, making it simple for end-users to command the model. However, this abstraction is a black box; developers preparing for the certification exam or aiming to build custom, deployable systems must understand what happens underneath. The code in this episode effectively reconstructs the hidden patterns, showing the explicit logic required to handle tool calls, manage message lists, and control the termination of reasoning cycles.

This lower-level understanding is indispensable for environments where you need to enforce strict governance, inject custom logging, or integrate with non-standard tool ecosystems. The walkthrough clarifies why the responsible pattern is to rely on the API's native tool-use protocols rather than trying to emulate high-level features. By examining the single Python file that replicates the Module 1 concepts, learners see the exact mechanics of implementing an orchestration layer that is transparent, debuggable, and completely under their control. This demystifies the platform's capabilities and equips developers with the skills to build robust, production-grade AI architectures from the ground up.

A self-contained testing sandbox

To ensure the lesson is immediately practical, the entire system is built around a synthetic, internal knowledge base rather than requiring a connection to live APIs or vector databases. This design choice removes significant friction for learners, avoiding the need to provision cloud resources or obtain extra API keys. The fake database contains enough varied information to simulate a realistic multi-hop research task, allowing the coordinator and sub-agents to exercise their retrieval and verification tools effectively. The environment simulates a sandboxed enterprise setting where agents query a controlled, internal document store.

Running the script reveals the end-to-end flow: the user issues a query, the coordinator interprets it and decides to seek evidence via a sub-agent, the sub-agent spawns and interacts with the synthetic data tool, and finally returns a source-attributed report. The testing section of the video demonstrates what healthy agentic behavior looks like, including proper tool-call formatting and stop-reason halts, and potentially illustrates common pitfalls that the architecture is designed to avoid. This run-through validates the design patterns, proving that a single carefully structured script can reliably orchestrate a multi-agent research team using only the standard SDK and a builder's understanding of prompt-guided state management.

Preparing for Domain 1 certification

This lesson serves a dual purpose: it functions as a general educational resource for AI engineers and as a direct study aid for the Claude Certified Architect exam. The content is explicitly mapped to Task Statements 1.1 through 1.7 of Domain 1, which constitutes a substantial 27% of the Foundations exam. Every line of code and architectural decision ties back to these formal objectives, covering the fundamentals of agent design, tool configuration, context management, and the practical implementation of coordination logic. Learners watching this episode are not just acquiring abstract knowledge but directly rehearsing the skills they will need to demonstrate during certification.

For exam preparation, understanding this practical synthesis is more valuable than memorizing theoretical definitions alone. The video translates formal task statements like "implement agentic loops" or "configure structured delegation" into concrete, working Python. By dissecting the code, viewers internalize the expected behaviors and troubleshooting patterns for agentic systems. The walkthrough highlights common mistakes and testable nuances, such as incorrectly handling a tool-use stop reason or mismanaging message state during delegation. This makes the module capstone a high-impact resource for anyone looking to validate their ability to architect solutions within the Anthropic ecosystem.

What you will learn

  • Implement an agentic loop using stop_reason instead of fixed iteration caps
  • Configure a coordinator agent that spawns sub-agents via custom delegation tools
  • Structure context passing with claim-source mappings to ensure traceability
  • Differentiate between Claude Code abstractions and raw Anthropic SDK patterns
  • Synthesize hypothetical research tasks using a simulated internal knowledge base

Concepts covered

Technologies used

Chapters 7 markers

  1. Introduction and Module 1 Recap
  2. Complete Code Walkthrough
  3. Implementing the Stop Reason Agentic Loop
  4. Building Coordinator and Subagent Tools
  5. Structured Findings and Source Mapping
  6. Raw SDK Pattern vs Claude Code Task Tool
  7. Running and Testing the Multi-Agent System

Next suggested video

Reviews

Student rating 0.0
0 reviews
Rate this lesson

Help other students decide if this lesson is useful.

No reviews yet. Be the first to rate this lesson.