Task statement 1.4 · Agentic architecture and orchestration

Implement multi‑step workflows with enforcement and handoff patterns

Before process_refund runs, the support agent must know whose account it is refunding, and when it escalates mid-case, the human taking over must be able to act without the transcript.

Scenario switchThis section runs on the Customer Support Resolution Agent, the guide's own setting for 1.4. Its tools are get_customer, lookup_order, process_refund and escalate_to_human. Its target is 80% first-contact resolution, and it may refund up to $500 on its own.
Why it's tested

When logs show the agent skipping get_customer, the natural fix is a firmer system prompt or few-shot examples of the right order. Both make the skip rarer but not impossible, because the model still chooses every tool call. A routing classifier that enables some tools changes which tools exist, not their order. Because the skipped step guards a refund, the rare miss sends money to the wrong account.

KnowledgePrompt guidance versus programmatic enforcement

Prompt-based guidance writes the ordering into the system prompt, so the model follows it most of the time. Programmatic enforcement puts the ordering in code outside the model: a hook, or a prerequisite gate, a check that refuses a tool call until an earlier step has returned its result. In the guide's production data, the guided agent skipped get_customer in 12% of cases and looked up orders by the customer's stated name, which occasionally refunded a misidentified account. When deterministic compliance is required, as with identity verification before financial operations, prompt instructions alone have a non-zero failure rate. Where a skipped step harms no one, a prompt instruction is proportionate and cheaper to change.

SkillWhere the prerequisite gate lives

Because the gate is your code, it keeps its own record. In an Agent SDK agent, PostToolUse, the hook that runs after a tool succeeds, records the verified customer ID that get_customer returned. PreToolUse, the hook that runs before a tool call executes, checks that record and blocks process_refund or lookup_order without it. The same check can live in the process_refund handler on the server, which also covers callers other than your agent.

  1. "J. Rivera" asks for a refund on order #12345.
  2. The model skips verification and calls process_refund.
  3. The PreToolUse hook finds no verified ID for the session and denies the call.
  4. The refund never runs; the denial tells the model to call get_customer.
  5. get_customer returns C-88431, and the PostToolUse hook records it.
  6. The retried process_refund passes the check.
verified = {}  # session_id → verified customer ID

async def record_verified(input_data, tool_use_id, context):
    customer = parse_customer(input_data["tool_response"])
    if customer.get("verified"):
        verified[input_data["session_id"]] = customer["customer_id"]
    return {}

async def require_verified(input_data, tool_use_id, context):
    if input_data["session_id"] in verified:
        return {}  # allow
    return {"hookSpecificOutput": {"hookEventName": "PreToolUse",
        "permissionDecision": "deny",
        "permissionDecisionReason": "Call get_customer first."}}

hooks = {"PostToolUse": [HookMatcher(matcher="mcp__support__get_customer", hooks=[record_verified])],
         "PreToolUse": [HookMatcher(matcher="mcp__support__process_refund|mcp__support__lookup_order",
                                    hooks=[require_verified])]}

Interactive · the same skip under two enforcement models

A refund request flows down to the model, which chooses the next tool. In 88% of cases it calls get_customer first and the refund goes to the right account. In 12% it skips get_customer. With prompt guidance the refund then runs on a name match; with a programmatic gate a PreToolUse check denies the call. "refund #12345 · J. Rivera" request arrives model picks the next tool prompt says: verify first 88% · verifies first 12% · skips get_customer get_customer returns verified ID C-88431 then process_refund refund runs verified account no check in code PreToolUse gate (your code) nothing stands in the way verified ID for this session? no call executes deny + reason refund runs on a name match refund tool never runs occasionally the wrong account agent calls get_customer next

Prompt guidance: the skip goes straight to the refund tool.

Programmatic gate: the same skip now ends at a denial.

Prompt guidance: nothing checks the model’s choice. The 12% is the guide’s figure for runs that skip get_customer; only some of those refund the wrong account. Programmatic gate: the model still skips get_customer as often as before, because nothing changed its choice. The gate changes the outcome: an unverified process_refund call is denied before it executes.

SkillOne message, three concerns

Verified customer C-88431 writes that the blender from order #12345 arrived cracked, that #12377 was charged twice, and that a returned espresso machine from #12390 was never refunded. Answering the blender and ending the turn loses two concerns and costs first-contact resolution. The agent should decompose the request into three distinct items and investigate each in parallel using shared context: one get_customer result serves all three, and the three lookup_order calls go out in one turn. Then it synthesizes a unified resolution: $89 refunded, the duplicate $42 refunded, and the $640 refund sent to a human because it exceeds $500.

SkillA handoff a human can act on

That third item is a mid-process escalation. An escalation is the agent handing the case to a person, and human agents lack access to the conversation transcript, so a one-line reason forces them to rebuild the case with the customer. A structured handoff protocol instead sends customer details, root cause analysis, the refund amount and a recommended action, plus what the agent already resolved.

Before

A reason the human cannot act on

escalate_to_human({
  "reason": "Customer is unhappy about
    a refund. Please assist."
})

The human has to contact the customer again.

After

A structured handoff summary

escalate_to_human({
  "customer_id": "C-88431",
  "root_cause": "Espresso machine from
    #12390 returned; refund never issued.",
  "refund_amount": 640.00,
  "recommended_action": "Approve full
    refund. Over the $500 agent limit.",
  "already_resolved": ["$89 refund #12345",
    "$42 duplicate charge #12377"]
})

The human can approve it without reopening the case.

The decision test If this step were skipped once in a thousand runs, would anyone lose money or be misidentified? Yes → enforce the order in code: a PreToolUse gate, or a check in the tool itself. No → a prompt instruction is proportionate.
Takeaway
  • A firmer prompt makes a skip rarer; only code that runs before the tool call makes it impossible.
  • PostToolUse records the verified ID, and PreToolUse denies the refund without it.
  • A mid-process handoff carries customer ID, root cause, refund amount and recommended action, because the human has no transcript.

check yourself

0 / 3 answered

Product asks the support agent to recap the agreed resolution before it ends each conversation. Logs show it skips the recap in about 6% of conversations. No refund, account change or tool call depends on the recap. Agent code ships on a two-week release cycle, while prompt edits ship the same day.Which is the most proportionate response?

Select one.

Human agents report that 70% of escalated cases need a callback to the customer to learn what the support agent already did. escalate_to_human currently takes only customer_id and a free-text reason. Compliance does not allow conversation transcripts to be copied outside the support system.Which TWO changes best let human agents act without contacting the customer again?

Select two.

Your PreToolUse hook allows process_refund once get_customer has been called in the session. Last week 4 refunds reached the wrong account. In each, get_customer had returned two customers matching the name given, and the agent picked one. The fix must not add work for the human team.Which change most directly closes this gap?

Select one.

sources

  1. Claude Docs, "Intercept and control agent behavior with hooks" (Agent SDK): callback signature (input_data, tool_use_id, context), HookMatcher registration, the mcp__<server>__<action> matcher form, session_id on every hook input, and permissionDecision: "deny" with permissionDecisionReason. Checked 2026-09-30.
  2. Claude Docs, "Hooks reference": PreToolUse runs "before a tool call executes" and can block it; PostToolUse input carries tool_response; on deny, the reason is shown to Claude. Checked 2026-09-30.
  3. The 12% skip rate and its "occasionally" misidentified accounts, the four tool names, and the handoff fields: Claude Certified Architect — Foundations Exam Guide v1.0, Domain 1.4, Scenario 1 and Sample Question 1. The $500 limit, the 80% target, and the orders and amounts are this course's scenario details.