[{"id":"ccdvf-workflow-vs-agent","courseId":"ccdv-f","domain":"agents-workflows","topic":"Workflow versus agent","prompt":"A finance team automates invoices: extract fields, check them against the purchase order, then draft a reply. Every invoice goes through the same three steps in the same order, and auditors want predictable behavior. Which architecture fits best?","hint":"Ask whether the model needs to decide the path, or whether code already knows it.","explain":"Workflows put code in charge of a sequence, with the model filling in each step. Agents let the model choose its next action from its tools until it judges the task done. Consider who should hold the steps.","source":"https://www.anthropic.com/engineering/building-effective-agents","interaction":{"type":"single"},"options":[{"id":"a","text":"A prompt-chaining workflow: code runs the three steps in order, one Claude call per step.","why":"Workflows orchestrate the model through predefined code paths and give predictability for well-defined tasks. When a task splits cleanly into fixed subtasks, prompt chaining keeps each call simple and lets code check results between steps. Reach for an agent only when the path can't be fixed in advance."},{"id":"b","text":"An autonomous agent with every tool available, which decides on each invoice which step to run next and when it is done.","whyNot":"Agents trade predictability for flexibility; nothing here needs the model to choose the path."},{"id":"c","text":"An orchestrator that spawns a dynamic number of worker subagents per invoice.","whyNot":"Orchestrator-workers suits subtasks you can't predict; these three steps are known in advance."},{"id":"d","text":"One large prompt that does all three steps at once at the highest effort level.","whyNot":"Merging fixed steps into one call removes the checkpoints that make each step easier and auditable."}],"answer":"a","explanation":"How much control code keeps versus the model is a design choice. The more the path is known ahead of time, the more control should sit in code, where it can be tested and audited.","concept":"How much control code keeps versus the model is a design choice. The more the path is known ahead of time, the more control should sit in code, where it can be tested and audited.","rev":1,"kind":"scenario","takeaways":["Fixed, known steps: workflow (prompt chaining). Open-ended path chosen at runtime: agent.","Start with the simplest design and add complexity only when it measurably helps."]},{"id":"ccdvf-orchestrator-workers","courseId":"ccdv-f","domain":"agents-workflows","topic":"Orchestrator-workers delegation pattern","prompt":"A migration tool must rename an API across a codebase. Which files change, and how many, depends on the request and the repository, so the list is only known after looking at the code. Which pattern fits best?","hint":"Which pattern lets a lead model plan the pieces after it sees the input?","explain":"Routing sends an input to one specialist prompt, and voting repeats a job to gain confidence. Chains run fixed steps in sequence. Each differs in whether code or the model decides how many pieces the work has.","source":"https://www.anthropic.com/engineering/building-effective-agents","interaction":{"type":"single"},"options":[{"id":"a","text":"Prompt chaining with a fixed list of steps written ahead of time.","whyNot":"A fixed chain assumes you know the subtasks up front, which this task doesn't."},{"id":"b","text":"Routing: classify the request and send it to one specialized prompt.","whyNot":"Routing picks one handler for an input; it doesn't break a task into a variable set of subtasks."},{"id":"c","text":"Orchestrator-workers: a lead model plans the subtasks at runtime and delegates them to workers.","why":"Orchestrator-workers is meant for tasks whose subtasks can't be predicted beforehand, such as code changes spread over an unknown set of files. The orchestrator plans at runtime, hands out focused pieces and merges the results."},{"id":"d","text":"Parallelization by voting: run the same full migration several times in parallel and keep the result most runs agree on.","whyNot":"Voting improves confidence on one task; it doesn't discover and split unknown subtasks."}],"answer":"c","explanation":"Agentic patterns differ in who decides the shape of the work. If the breakdown can only be found by looking at the input, the planning step has to happen at runtime, not in code.","concept":"Agentic patterns differ in who decides the shape of the work. If the breakdown can only be found by looking at the input, the planning step has to happen at runtime, not in code.","rev":1,"kind":"scenario","takeaways":["Unknown number or kind of subtasks: orchestrator-workers.","Known independent pieces: parallelization (sectioning). Same task many times: voting."]},{"id":"ccdvf-subagent-context-isolation","courseId":"ccdv-f","domain":"agents-workflows","topic":"Subagents for context isolation","prompt":"An Agent SDK research agent reads dozens of files and search results per question. After a while the main conversation is full of raw tool output and answer quality drops. Which change addresses the cause?","hint":"Think about where the raw tool output lives and what gets returned to the main conversation.","explain":"Every tool call and result is appended to the conversation the model reads on each turn. Compare whether that history stays in one thread or is split, and what crosses between threads.","source":"https://code.claude.com/docs/en/agent-sdk/subagents","interaction":{"type":"single"},"options":[{"id":"a","text":"Raise max_tokens so the agent has more room to write complete answers.","whyNot":"max_tokens caps output length; it does nothing about bloated input context."},{"id":"b","text":"Delegate the reading to a subagent and return only its final summary to the main conversation.","why":"Each subagent runs in its own conversation, and its intermediate tool calls and results stay inside it. Only the final message returns to the parent, so the main context gets a concise summary instead of every file. That keeps the lead agent focused as work grows."},{"id":"c","text":"Add a system prompt rule telling the agent to ignore search results older than the last three turns when it answers.","whyNot":"The old output still fills the context and dilutes attention; an instruction doesn't remove it."},{"id":"d","text":"Run the same agent twice and merge both answers.","whyNot":"Both runs suffer the same bloated context, and merging doubles cost."}],"answer":"b","explanation":"A model's attention is spread over everything in its context, so noise lowers quality. Keeping exploration in a separate context and passing back only conclusions protects the main thread.","concept":"A model's attention is spread over everything in its context, so noise lowers quality. Keeping exploration in a separate context and passing back only conclusions protects the main thread.","rev":1,"kind":"scenario","takeaways":["Subagents isolate context: the parent sees the result, not the exploration.","Use them for noisy, read-heavy subtasks and for independent work that can run in parallel."]},{"id":"ccdvf-sdk-posttooluse-hook","courseId":"ccdv-f","domain":"agents-workflows","topic":"Hooks for deterministic actions","prompt":"A coding agent built on the Agent SDK must run the project formatter after every file it writes, with no exceptions. The rule is in the system prompt, but logs show the agent skips it on some runs. Which change guarantees it?","hint":"Look for the option that runs your code at a lifecycle event instead of asking the model.","explain":"A system prompt is text the model reads and weighs, so compliance varies between runs. The agent runtime can also call functions you supply at set moments, such as before or after a tool executes.","source":"https://code.claude.com/docs/en/agent-sdk/hooks","interaction":{"type":"single"},"options":[{"id":"a","text":"Repeat the rule in capitals at the start and end of the system prompt.","whyNot":"Prompt wording still leaves the choice to the model, so it can still be skipped."},{"id":"b","text":"Expose the formatter as a tool and ask Claude to call it after each edit.","whyNot":"Calling the tool is still the model's decision; nothing forces it."},{"id":"c","text":"Raise the effort level so the agent follows instructions more carefully.","whyNot":"Effort changes how much work Claude does, not whether a rule is enforced."},{"id":"d","text":"Register a PostToolUse hook with a Write|Edit matcher that runs the formatter.","why":"Hooks run your code at fixed points in the agent lifecycle, such as after a tool returns. A PostToolUse hook matched to Write and Edit fires on every file write, whatever the model decides. Use hooks for actions that must always happen, and prompts for guidance."}],"answer":"d","explanation":"Instructions to a model are probabilistic: it usually complies, but not always. Rules that must hold every time belong in deterministic code tied to agent lifecycle events.","concept":"Instructions to a model are probabilistic: it usually complies, but not always. Rules that must hold every time belong in deterministic code tied to agent lifecycle events.","rev":1,"kind":"scenario","takeaways":["Must always happen: hook. Should usually happen: prompt.","PreToolUse can block a call; PostToolUse reacts after a tool succeeds."]},{"id":"ccdvf-managed-agents-hosting","courseId":"ccdv-f","domain":"agents-workflows","topic":"Anthropic-hosted versus self-run agents","prompt":"A small team needs an agent that runs hour-long tasks with bash and file tools in a secure sandbox, keeping files between sessions. They have no one to build or operate an agent loop, sandbox or tool-execution layer. Which approach fits best?","hint":"Who runs the loop and the sandbox in each option?","explain":"A single Messages API request returns once and keeps no state, so long tasks need a process keeping the loop alive. A sandbox isolates commands and file edits from your systems.","source":"https://platform.claude.com/docs/en/managed-agents/overview","interaction":{"type":"single"},"options":[{"id":"a","text":"Claude Managed Agents, with sessions in an Anthropic-managed cloud sandbox.","why":"Managed Agents is a hosted agent harness: Anthropic runs the loop, tool execution and the sandbox, with persistent sessions. It targets long-running work with minimal infrastructure. The Agent SDK and the Messages API suit teams that want to run the agent in a process they operate."},{"id":"b","text":"The Messages API with a hand-written tool loop and their own containers.","whyNot":"That works, but it means building and running exactly the infrastructure they lack."},{"id":"c","text":"The Agent SDK inside a service they deploy and operate themselves.","whyNot":"The SDK gives them the loop, but they still host the process and its sandbox themselves."},{"id":"d","text":"The Message Batches API, since the tasks are long-running.","whyNot":"Batches process independent Messages requests; they don't run tools or keep a sandbox."}],"answer":"a","explanation":"Running an agent means owning a loop, tool execution, a sandbox and state. Hosting options differ mainly in how much of that stack you operate yourself versus hand to Anthropic.","concept":"Running an agent means owning a loop, tool execution, a sandbox and state. Hosting options differ mainly in how much of that stack you operate yourself versus hand to Anthropic.","rev":1,"kind":"scenario","takeaways":["Managed Agents: Anthropic hosts the harness and sandbox (a self-hosted sandbox is also possible).","Agent SDK: Claude Code's loop and tools in a process you operate."]}]