CCDV-P Study Guide
1. Domain 1: Advanced Agent Architecture and Orchestration
1.3. 1.3 Architecture selection at scale: evolving between workflows and agents
CCDV-P · Domain 1 · Lesson 1.3 · 21 min read
Read cost, failure, quality and variance per path to move a live system between workflow and agent, pick its harness, and set shared team standards.
Why a system that works can still be the wrong shape
Brightwell Health's imaging team shipped a prior-authorisation assistant six months ago. Before a hospital can perform an MRI or CT scan, the patient's insurer must approve it, and the request needs the right coverage check, the insurer's criteria and evidence from the patient's chart. The team built it as a full agent: Claude gets the request and a set of tools, and decides which to call and in what order. A nurse reviews every packet before it goes to the insurer. It works. Nurses accept most packets without edits.
Then finance asks why it costs three times the estimate: about $65,000 a month for 38,000 requests, against a forecast of $21,000. At the same time, the specialty-pharmacy team wants to replace its own fixed workflow with an agent, and the surgical-services team is about to start building and asks which harness to use. Tomasz, who leads Brightwell's platform team, has to answer all three.
None of these questions is about whether agents are good. Anthropic's own guidance draws the line plainly: a workflow runs model calls and tools through code paths you defined in advance, while an agent lets the model direct its own process and tool use. Agents buy flexibility with latency and cost. The question at scale is which parts of a live system earn that price, and the answer is in the production data you already collect.
Reading the production record: paths, not averages
Here is the mistake that stalls most of these reviews: the team looks at averages. Average cost per request is $1.70, average acceptance is 90%, and nothing in those two numbers says what to change. An agent's traces hold something better: the sequence of tools it actually called on every request. Group requests by that sequence, the path, and the averages split into cohorts you can act on.
The script below does that from exported trace records. The line that matters is the one building path: it keeps each tool once, in order of first use, so a request that called get_payer_criteria twice still lands in the same cohort as one that called it once. The repeats are exactly the waste you are hunting.
from collections import defaultdict
from statistics import median, quantiles
def path_report(traces):
cohorts = defaultdict(list)
for t in traces: # one record per completed request
tools = [c["tool"] for c in t["tool_calls"]]
path = tuple(dict.fromkeys(tools)) # COLLAPSE repeats: same steps, same cohort
cohorts[path].append(t)
for path, items in sorted(cohorts.items(), key=lambda kv: -len(kv[1])):
costs = sorted(t["cost_usd"] for t in items)
p95 = quantiles(costs, n=20)[-1] if len(costs) > 1 else costs[0]
accepted = sum(t["nurse_accepted"] for t in items) / len(items)
calls = median(t["model_calls"] for t in items) # model turns, not tool calls
print(f"{len(items)/len(traces):5.0%} ${median(costs):.2f} p95 ${p95:.2f} "
f"accepted {accepted:.0%} calls {calls} {' > '.join(path)}")
Run on six months of Brightwell traces, the report has one dominant line. 82% of requests take the same four steps: check_member_eligibility, get_payer_criteria, read_chart_notes, then draft_auth_packet. On that path the agent makes a median of nine model calls for four tool calls, because it re-reads the chart and fetches the criteria twice to be sure. The other 18% scatter across dozens of paths: missing chart pages, two procedures in one request, an insurer policy that cannot be found, a retroactive request.
Four signals come out of a report like this, and each points somewhere different.
| Signal | What Brightwell's data shows | What it points to |
|---|---|---|
| Cost per task, by path | Stable path median $1.45; long tail median $2.80 | The stable path spends model turns on choices code could make |
| Failure rate by step | 2.6% of stable-path packets miss a required attachment at step 4 | A deterministic check belongs at that step, not a better prompt |
| Quality score, by path | Nurse acceptance 93% on the stable path, 79% on the long tail | The long tail is harder, but the agent still helps there |
| Variance | Stable-path p95 cost is almost three times its median, on requests that look alike | The model takes different routes through the same job |
Memorise the four signals and what each isolates; the numbers are only illustration. High variance on identical-looking work is the sharpest hint: the model is making decisions the task does not need.
Pinning the stable path: from agent to workflow
It is tempting to read Brightwell's bill and say "rebuild it as a workflow". Resist it completely. The data supports pinning one path, not deleting the agent. The 18% long tail is exactly the work a fixed sequence cannot anticipate, and nurses still accept four in five of those packets.
Pinning means taking a path the agent already follows and writing it as code. Your program calls the four tools in order and makes model calls only where judgement is needed: matching chart evidence to the insurer's criteria, and drafting the packet. A router in front decides which requests take the pinned path. It is plain code, not a model guess: the request names one procedure code, eligibility returns an active plan, exactly one payer policy matches, and the chart is attached. Anything else goes to the agent. And if any workflow step's check fails mid-way, the request falls off the path and the agent takes over from there.
Brightwell's proposed hybrid
Think of a hospital's admissions desk. Routine admissions follow a checklist any clerk can run; unusual ones go to the senior coordinator, who decides as she goes. Nobody would have her handle every routine case, or fire her because most cases are routine.
The evidence that justifies pinning has three parts, and you need all three. First, concentration: one path carries most of the volume and has stayed stable for months. Second, quality that does not depend on the model choosing the route: acceptance on that path is high, and the failures cluster at a step a code check can catch, such as the missing attachment. Third, a cost or latency gap the agent's extra turns explain. Tomasz then validates before switching: he replays two weeks of past stable-path requests through the workflow and compares nurse-acceptance grades against what the agent produced. The replay projects about $0.40 per pinned request, and the attachment check removes the 2.6% failure at step 4.
Opening a workflow up: from workflow to agent
The specialty-pharmacy team has the opposite problem. Its drug prior-authorisation system is a fixed workflow: look up the drug, check the formulary, fill the insurer's form. Anything the code cannot handle goes to an exceptions queue that a pharmacist works by hand. That queue grew from 9% to 24% of 21,000 monthly requests after insurers added step-therapy rules, which require proof that cheaper drugs were tried first. Each exception takes a pharmacist about 35 minutes.
The team wants to replace the whole workflow with an agent. The data supports something narrower, and the first step is the same as before: cluster the queue by reason. If 80% of exceptions turn out to be one new rule with a predictable lookup, the fix is a new workflow branch, not an agent. Brightwell's queue looks different: the medication history sits in free-text notes, pharmacy claims and outside records, in no fixed place, and the alternatives differ by insurer. That is open-ended search, the work agents are for.
The evidence each direction needs
Pin agent path into workflow
Validate by replaying past requests
Open workflow up to agent
Validate by shadow runs on past cases
The evidence for opening up has three parts too. The fall-through rate by reason shows the fixed paths no longer cover the work. The reasons are too varied to enumerate as branches. And a shadow run wins: the agent processes last month's queued cases without its output reaching insurers, pharmacists grade those packets against their own, and the cost per case is compared with 35 pharmacist minutes. The agent then takes over only the exception cohort, with a turn cap and a budget per case. The 76% the workflow handles well stays a workflow.
Choosing the harness
Surgical services asks the next question: which harness? A harness is everything around the model that turns its decisions into actions: the loop, tool execution, permissions, session state. Claude decides and requests; the harness executes and enforces. Brightwell has four first-party options, and four questions decide between them: who hosts the loop, where tools run and how they are sandboxed, where session state lives, and who operates it all.
| Harness | Hosting and sandbox | Session state | Wins when |
|---|---|---|---|
| Messages API loop you own | Your service runs the loop and every tool; the SDK's tool runner (beta) can drive the loop for you | Yours to store and resend with each request | You need full control inside a service you already run, with a small set of custom tools |
| Agent SDK | Claude Code's loop and built-in tools as a Python or TypeScript library, in containers you host and sandbox | Transcripts on local disk; a SessionStore adapter mirrors them to durable storage |
You want Claude Code's tools, permissions, hooks and sessions inside your own application |
Claude Code headless (claude -p) |
The CLI, run where you run it: a CI runner or a scheduled job | Resumable by session id with --resume |
Scripted engineering tasks in pipelines, with --output-format json for parsing |
| Claude Managed Agents (beta) | Anthropic hosts the loop; tools run in an Anthropic cloud sandbox or a self-hosted sandbox | Stored server-side until you delete it | Long-running or scheduled work with minimal infrastructure to operate |
Memorise the four rows and the four deciding questions. One more filter comes first in a regulated environment: data handling. Brightwell's requests carry protected health information under a HIPAA Business Associate Agreement (BAA), the contract US health-privacy law requires before a vendor handles patient data. Anthropic's API and data retention page lists, feature by feature, what its HIPAA readiness arrangement covers. The Messages API is listed as eligible. Claude Managed Agents is not, across all its sub-features, and Claude Code is named as not covered.
That page also says the signed BAA is the source of truth, so Brightwell's compliance officers, not Tomasz's engineers, confirm coverage. With that confirmed, the patient-data path for surgical services runs on a Messages API loop Brightwell owns, reusing the imaging team's router and tools. That also fits the job: six custom tools, no shell or file access needed, and the SDK's built-in tools would be capability the work does not use.
The other harnesses still have homes, outside the patient-data path. HIPAA readiness applies to a whole API organisation, and the docs advise a separate organisation for work that does not need it; Brightwell keeps one for engineering. There, Tomasz's team runs Claude Code headless in CI to replay the evaluation set against de-identified cases whenever a router rule changes. And a nightly job that reads public insurer policy bulletins and flags criteria changes is a natural fit for Managed Agents: public data, long-running, and nobody wants to operate a container for it.
Third-party frameworks, such as graph-based orchestration libraries and multi-agent role frameworks, play the same role as the Agent SDK: they supply a loop and abstractions. Judge them with the same four questions, plus two more. Can you see the exact prompts and responses they send? Anthropic's guidance warns that abstraction layers can hide both and make debugging harder. And who maintains the framework when the Claude features you depend on change?
Standards that three teams can share
With three teams building on Claude, Tomasz finds the cost of everyone rolling their own. There are three versions of the eligibility tool: one returns plan codes, one plan names, and one has no timeout, which is why imaging saw eligibility failures at step 1. Each team keeps its own system prompt with its own wording of the patient-data rules, and only imaging has an evaluation set. Every fix happens three times, or once.
Reusable-pattern standards are the shared, tested pieces that every team builds on. Brightwell's platform team owns three.
- SHARED TOOL DEFINITIONS. One implementation of
check_member_eligibility,get_payer_criteriaandread_chart_notes, with one name, description and input schema, exposed through an internal MCP server. Versioned, with timeouts and error results built in once. - PROMPT TEMPLATES. A base system prompt with the patient-data rules and output format, plus variables each team fills in. Templates live in version control, and a change merges only when the shared evaluation set passes.
- SKILLS. A Skill is a folder with a
SKILL.mdfile whose name and description Claude always sees, and whose instructions load only when a task matches. Brightwell's engineers share Skills for writing a new insurer adapter and for running the replay, as a Claude Code plugin. Each passes the enterprise review checklist and its own trigger tests before it is published. Anthropic lists Agent Skills on the API as not HIPAA-eligible, and Claude Code is not covered either, so these Skills serve engineering work on de-identified data and none sits on the patient-data path.
What the platform team standardises
Standards beat each team rolling its own for concrete reasons: one fix reaches every product, one security review covers each tool, and an identical trace schema makes the path report comparable across teams, so the next architecture review starts from data. What Tomasz does NOT standardise is the architecture itself. Imaging gets a hybrid, pharmacy keeps a workflow with an agent for exceptions, and surgical services starts with the pinned workflow and opens it up only if the data asks.
The exam traps
Every trap here changes the system without reading the evidence, or reads it at the wrong level.
- ✗ Rebuilding the whole agent as a workflow because the bill is high. ✓ Pin only the path the data shows is stable, route it with code, and keep the agent for the long tail. The long tail is where the agent earns its cost.
- ✗ Replacing a workflow with an agent because the exceptions queue keeps growing. ✓ Cluster the queue by reason first. A single new rule needs a branch; only varied, open-ended reasons justify an agent, and then only after a shadow run beats the current handling.
- ✗ Judging the architecture by averages across all traffic. ✓ Group traces by path and read cost, failure by step, quality and variance per cohort. An average mixes the cohort that needs pinning with the one that needs the agent.
- ✗ Fixing wasted turns with a different model tier or a prompt rule such as "use at most four tools". ✓ Move the fixed sequence into code. A prompt cannot enforce a sequence, and a model swap leaves the unneeded decisions in place.
- ✗ Picking a harness for the fastest demo, or Managed Agents for a patient-data workload. ✓ Filter by data-handling eligibility, then decide by hosting, sandboxing, session state and operational ownership.
- ✗ Letting each team write its own tools, prompts and Skills. ✓ Share versioned tool definitions, prompt templates and reviewed Skills behind one evaluation gate, so one fix and one review reach every product.
Put it together: decide from your own traces
You now have every piece: the path report, the evidence for each direction, the router and fall-off, the four harness questions and the standards that keep three teams consistent. The fastest way to own them is to run the analysis yourself on data you generate, then break the router and watch the wrong requests take the fixed path.
The rest of this domain builds on the same evidence. Multi-agent orchestration (1.1) decides how the agent that handles the long tail splits its work. Cost optimisation techniques (6.1), such as caching and model routing, tune whichever architecture you keep. Organisation-wide Claude Code configuration (8.4) turns the Skills and plugin standards into policy across every team.
Key takeaways
- ✓ Workflows run model calls and tools through code paths you define; agents let the model choose its own steps, trading cost and latency for flexibility.
- ✓ Group traces by path and read cost per task, failure rate by step, quality and variance per cohort, never as averages across all traffic.
- ✓ Pin a path into a workflow when it is concentrated, its quality does not depend on the model choosing the route, and unneeded turns explain its cost; keep the agent for the long tail behind a code router.
- ✓ Open a workflow up to an agent only when fall-throughs are growing, too varied for branches, and a shadow run beats the current handling on that cohort.
- ✓ Choose the harness by who hosts the loop, sandboxing, session state and operational ownership, after filtering by data-handling eligibility.
- ✓ Standardise shared tool definitions, prompt templates, Skills, the evaluation set and the trace schema, and leave each architecture decision to its own data.
Practise this
Practice questions for CCDV-P are being written and are not in this course yet. Read this lesson on the web to answer its check questions, with every option explained: https://claude.termidy.com/learn/ccdv-p/advanced-agent-architecture/architecture-selection-at-scale/.