By Sagar Shankaran, Founder of CallSphere
Code-level patterns for Claude agents: role contracts, guarded tools, context slices, structured results, and rubric-as-data verifiers.
Key takeaways
The third time you build a Claude Managed Agent, you stop reinventing structure and start reaching for patterns. The same shapes keep working: how you frame the orchestrator's job, how you scope a tool so the model uses it correctly, how you pass context to a subagent without drowning it. This post is a pattern catalog — reusable, code-level building blocks for outcome-driven and multi-agent systems on Claude, with the prompt scaffolding that makes each one reliable.
Patterns are not rules; they are defaults that survive contact with production. Each one below earned its place by failing first in some other form. I will show the shape, the prompt or schema that anchors it, and the failure mode it prevents.
The most common mistake is prompting the orchestrator like a script: "First do X, then Y." That fights the model's strength. Instead, give it a role and a contract. Tell it what it is responsible for, what tools and subagents it commands, what "done" means, and what it must never do. Then let it plan.
You are the orchestrator for a reconciliation outcome.
RESPONSIBILITY: deliver a report meeting every success criterion below.
YOU COMMAND: subagents [ledger_fetcher, invoice_fetcher, comparator].
DONE WHEN: all criteria pass the verifier.
NEVER: mutate external systems; trust a subagent's "done" without
checking its output against the criteria.
SUCCESS CRITERIA:
- every invoice line matched or flagged
- totals recomputed independently
This framing consistently produces better decompositions because the model owns the goal rather than executing a brittle recipe. When inputs surprise it, a role-contracted orchestrator adapts; a scripted one derails.
The "NEVER" clauses earn their keep more than any other part of the contract. They are cheap to write and they close off whole categories of failure: an orchestrator that knows it must never mutate external systems will route mutations to a gated tool rather than improvising one; an orchestrator told never to trust an unverified "done" will actually invoke the verifier instead of taking a worker's word. Treat the never-list as a small policy the model carries through every turn. When you discover a new failure mode in a trace, the fix often belongs here as one more line, not as a rewrite of the whole prompt.
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
A tool definition is read by the model every turn, so it is prompt real estate. The pattern: each description states what the tool does, when to reach for it, and what not to do with it. Inputs are tightly typed; outputs are structured so the next step does not have to parse prose.
flowchart TD
A["Orchestrator role contract"] --> B["Plan: decompose outcome"]
B --> C["Select tool by description"]
C --> D{"Inputs valid vs schema?"}
D -->|No| E["Repair args, retry once"]
D -->|Yes| F["Tool returns structured result"]
F --> G["Attach result to durable state"]
G --> H["Reconcile vs success rubric"]
The validate-and-repair node in that flow is itself a pattern: when arguments fail the schema, let the model see the validation error and retry once before escalating. Most argument errors are self-correcting if you feed the error back; blind retries without the error are just dice rolls.
Subagents fail when they are handed too much. The pattern is to construct a minimal context slice: the subtask goal, only the inputs it needs, and an explicit acceptance test it can self-check against. Everything else — the report's narrative, the orchestrator's reasoning — stays out.
subagent_brief = {
"goal": "Fetch all PO lines for vendor V-204, Q1.",
"inputs": {"vendor_id": "V-204",
"start_date": "2026-01-01",
"end_date": "2026-03-31"},
"acceptance": "Return one row per PO line; non-empty if POs exist; "
"include line_id, qty, unit_price.",
"tools_allowed": ["get_purchase_orders"]
}
The acceptance field is the quiet hero. It lets the subagent grade its own output before returning, which catches empty or malformed results at the edge instead of letting them poison the comparison three steps later.
There is a subtle discipline here worth naming: the slice should be built by the orchestrator at delegation time, not copied wholesale from its own context. It is easy to slip into handing a subagent "everything I know so far" because it feels safer. It is not. A subagent that receives the orchestrator's full reasoning starts second-guessing the plan instead of executing its slice, and it burns tokens re-deriving decisions that were already made. The slice is a contract: here is your goal, here are your inputs, here is how you know you succeeded, and nothing else is your concern.
Make every subagent return a typed object with a status, the payload, and a short note — never a free-text blob the orchestrator must re-parse. When results are structured, reconciliation becomes a comparison over fields, not an act of reading comprehension. A worker that returns {"status": "ok", "rows": [...], "note": "12 PO lines, 1 zero-qty"} is trivially reconcilable; one that returns a paragraph is not.
This pattern also makes runs debuggable. When something goes wrong, a structured trace tells you exactly which subagent returned what, with what status. Free-text traces force you to re-read the model's prose to reconstruct what happened. The note field is where you let the worker editorialize briefly — a one-line human-readable summary that helps you skim a trace — while the status and payload stay strictly machine-consumable.
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
A useful refinement is to standardize the result envelope across every subagent type so the orchestrator never has to special-case shapes. Whether a subagent fetched rows, ran a comparison, or summarized findings, it returns the same outer object — status, payload, note — and the payload varies underneath. That uniformity means your reconciliation logic, and the verifier, can be written once against the envelope rather than re-implemented per subagent. It also makes adding a new subagent type cheap: as long as it speaks the envelope, the orchestrator already knows how to consume it.
Encode success criteria as a list the verifier iterates over, each with an id, an assertion, and a how-to-check note. The verifier then returns a per-criterion verdict, not a single thumbs-up. This turns "did it pass?" into "which criteria passed and which failed?" — which is what the orchestrator needs to decide whether to iterate and on what.
| Pattern | Prevents | Anchor |
|---|---|---|
| Role contract | Brittle scripted plans | System prompt |
| Guarded tools | Misuse, opaque calls | Tool description + schema |
| Context slice | Drowned subagents | Subagent brief |
| Structured results | Re-parse errors | Typed return object |
| Rubric-as-data | Vague pass/fail | Criteria list |
Because Claude plans well when it owns the goal but follows recipes poorly when inputs deviate. A role contract states responsibility, authority, and constraints, then lets the model decompose — which adapts gracefully to surprises that a fixed script would crash on.
As small as the subtask's acceptance test allows. Include the goal, the exact inputs, the allowed tools, and a checkable definition of success — and nothing about other subtasks. If removing a piece of context would not change whether the subagent can pass its acceptance test, leave it out.
Yes. They are general agent-engineering patterns; the role contract, guarded tools, context slices, structured results, and rubric-as-data all apply equally when you write your own loop with the Agent SDK. Managed Agents just give you a runtime that expects work shaped this way.
CallSphere leans on these exact patterns to keep voice and chat agents reliable under live pressure — role-contracted orchestration, guarded tools, and verified outcomes per call. Hear the patterns at work at callsphere.ai.
Source & attribution: This is an independent, original explainer inspired by Anthropic's coverage on the Claude blog. Claude, Claude Code, Claude Cowork, Claude Opus, and the Model Context Protocol are products and trademarks of Anthropic. CallSphere is not affiliated with or endorsed by Anthropic.

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
A resin increase means re-costing hundreds of part numbers one at a time. Splitting the list four ways by contract rule moves the pass-through weeks earlier.
Anthropic's Claude Fable 5 and Mythos 5 explained: pricing, availability, frontier benchmarks, the dual-model safeguard architecture, and what they mean for AI agents.
Where Claude Code, MCP, and multi-agent systems are taking GTM engineering next, and how to prepare your team now for standing and multi-agent workflows.
Where Claude Cowork and the Claude agent ecosystem are heading next — standing agents, MCP, skills as a moat — and the concrete moves to prepare your team now.
The metrics, leading signals, and anti-metrics that prove Claude Cowork is working — acceptance rate, time-to-outcome, and why usage counts mislead.
Shipping an agentic GTM workflow is easy; proving it works is hard. The metrics, signals, and eval loops that show a Claude Code rebuild is paying off.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco
Watch how CallSphere handles real customer calls, schedules appointments, and processes payments — live.
Try Live DemoBook a DemoCalculate Your ROI