Rubric
Contents — domains, guide and mocks

Enforcement and handoff in multi-step workflows

CCAR-F 1.49 min read · checked 21 September 2026

Task statementImplement multi-step workflows with enforcement and handoff patterns

Guidance versus enforcement

A system prompt that says “always verify the customer before processing a refund” will be followed most of the time. The guide's point is that most of the time is not good enough when the rule is a compliance requirement: prompt instructions have a non-zero failure rate. When ordering must be deterministic, enforce it programmatically.

Anthropic's Claude Code guidance makes the same distinction in its own words: instructions in CLAUDE.md are advisory, while hooks are deterministic and guarantee the action happens. The same logic applies to any agent. If you can state a rule as a condition your code can check — a verified id exists, an amount is under a limit, a status is “approved” — then check it in code and let the prompt handle everything that is a matter of judgement.

Prompt-based guidanceProgrammatic enforcement
How it worksInstruction in the system promptA hook or prerequisite gate in code
ReliabilityProbabilisticDeterministic
Right forStyle, tone, preferred orderIdentity checks, financial limits, compliance
Failure looks likeOccasional skipped stepBlocked call with a clear reason

Instruction or enforcement?

What happens if the step is skipped once?
  • Money moves or law is broken
    Gate it in codeblock the tool until the prerequisite holds
  • Wrong person's data is exposed
    Gate it in codecheck identity before any lookup
  • The reply is slightly worse
    Prompt guidancetone, format, preferred order
Ask what a single skipped step would cost. If the answer involves money, law or someone else's data, a prompt alone is the wrong tool.

Prerequisite gates

A gate blocks a downstream tool until an upstream step has completed. The canonical example: process_refund is refused unless get_customer has already returned a verified customer id in this session.

A prerequisite gate in the tool dispatcherpython
def run_tool(name, args, session):
    if name == "process_refund":
        if not session.verified_customer_id:
            # returned to Claude as a tool_result with is_error set
            return tool_error(
                category="validation",
                retryable=False,
                message="Verify the customer with get_customer before a refund.",
            )
        if args["customer_id"] != session.verified_customer_id:
            return tool_error(
                category="permission",
                retryable=False,
                message="Refund target does not match the verified customer.",
            )
    result = TOOLS[name](**args)
    if name == "get_customer" and result.get("verified"):
        session.verified_customer_id = result["id"]
    return result

The blocked call returns a structured error the model can act on — here, by calling get_customer first. In the Messages API that means a tool_result with is_error set and a message that says what to do next; the tool-use documentation specifically recommends instructive errors over a bare “failed”. Structured tool errors are covered properly in 2.2, and the Agent SDK's hook-based version of the same gate is covered in 1.5.

Notice two details. The gate records state from a successful upstream call (verified_customer_id) rather than trusting the model's claim that it verified someone. And it checks that the refund is for the same customer who was verified — a gate that only asks “has anyone been verified?” can be satisfied by the wrong person.

The gate in action

Claude
Your dispatcher
Refund system
Step 1: Claude to Your dispatcher: process_refund(C-20931, 2499)
Step 2: Your dispatcher to Claude: Error: verify customer first
Step 3: Claude to Your dispatcher: get_customer(C-20931)
Step 4: Your dispatcher to Claude: Verified · id recorded
Step 5: Claude to Your dispatcher: process_refund(C-20931, 2499)
Step 6: Your dispatcher to Refund system: Execute refund
Step 7: Refund system to Your dispatcher: Refund reference R-5521
The model tried to skip a step; the dispatcher refused and said why; the model recovered on its own. Nothing reached the refund system until the rule held.

Multi-concern requests

Customers bundle problems: a late delivery, a double charge and an address change in one message. Decompose them into distinct items, investigate each — in parallel where they are independent, using shared context such as the customer record — then synthesise one resolution. Handling them as a single blob tends to resolve the loudest issue and drop the rest.

Structured handoff

When the agent escalates to a human mid-process, the human usually cannot see the transcript. A handoff that says “customer is upset about a refund” forces them to start again. A structured summary lets them act immediately.

What a human agent needsjson
{
  "customer_id": "C-20931",
  "issue": "Charged twice for order 88412",
  "root_cause": "Payment retried after a gateway timeout; both captures succeeded",
  "actions_taken": ["Verified identity", "Confirmed duplicate capture"],
  "recommended_action": "Refund one capture of INR 2,499",
  "why_escalated": "Refund exceeds the agent's automatic limit"
}

Checking a weak handoff note

  • Missing: Who the customer isno customer id
  • Check: What the issue is“refund” — for which order?
  • Missing: Root cause found so far
  • Missing: Actions already takenwas identity verified?
  • Missing: Recommended next action
  • Missing: Why it was escalatedlimit, policy, or anger?
  • Passes: Customer sentimentthe one thing it does say
The note “Customer upset about refund, please help” checked against what the receiving human needs. Only one item survives.

Traps the wrong answers are built from

Tempting but wrongDo this instead
Relying on the system prompt for a compliance-critical order of stepsBlock the downstream tool until the prerequisite has completed.
Escalating with a one-line summaryHand off customer id, root cause, actions taken and a recommended action.
Treating a multi-issue message as one problemSplit into items, investigate each, then synthesise one reply.
A gate that trusts the model's claim that a step happenedRecord state from the upstream tool's actual result and check it.
A bare “failed” when the gate blocks a callReturn an instructive error naming the step that must come first.

You should now be able to

  • Implement prerequisite gates that block a tool until an earlier step has succeeded.
  • Decompose multi-concern requests and investigate the parts before one resolution.
  • Compile structured handoff summaries for humans who lack the transcript.
  • Decide when a rule needs enforcement rather than instruction.
  • Write gate errors that let the model recover by itself.

Practice questions

Original questions written for this lesson, in the exam’s style. Answer first, then open the reasoning — every option is explained, including why the wrong ones are tempting.

  1. Question 1

    Policy requires identity verification before any refund. The system prompt says so in capital letters, yet an audit finds 0.4% of refunds were issued without verification.

    What is the most effective change?

    1. AMove the instruction to the top of the system prompt and repeat it.
    2. BAdd few-shot examples that show verification before each refund.
    3. CSwitch to a more capable model that follows instructions better.
    4. DBlock process_refund until get_customer returns a verified id.
    Show answer and reasoning
    1. AIncorrect. Still a probabilistic instruction; it may lower the rate but will not eliminate it.
    2. BIncorrect. Improves consistency but remains guidance, not a guarantee.
    3. CIncorrect. Reduces errors but does not make compliance deterministic.
    4. DCorrect. A deterministic requirement needs deterministic enforcement in code.
  2. Question 2

    An agent escalates to a human team who cannot see the conversation. What should the handoff contain?

    1. AThe full raw transcript, so nothing at all is lost in the handover.
    2. BA sentiment score and the customer's most recent message.
    3. CCustomer id, root cause, actions taken and a recommended step.
    4. DNothing — the human should ask the customer to repeat the issue.
    Show answer and reasoning
    1. AIncorrect. Complete but slow to act on; the human must re-derive everything from it.
    2. BIncorrect. Neither tells the human what happened or what to do next.
    3. CCorrect. A structured summary lets the human act without re-investigating.
    4. DIncorrect. Forcing the customer to start again is the outcome handoff exists to avoid.
  3. Question 3

    A bank is reviewing the rules in its account-servicing agent's system prompt.

    Which TWO rules most need programmatic enforcement rather than prompt instructions? (Select 2.)

    1. AConfirm the caller's identity before showing any balance.
    2. BAddress the customer by first name where appropriate.
    3. CNever move more than the daily transfer limit automatically.
    4. DKeep replies under about 150 words unless asked for detail.
    5. EOffer a satisfaction survey link at the end of each chat.
    Show answer and reasoning
    1. ACorrect. Showing one person's data to another is a compliance failure; it must hold every time.
    2. BIncorrect. A style preference; an occasional miss costs nothing, so prompt guidance is fine.
    3. CCorrect. A financial threshold is exactly what a gate or hook should enforce deterministically.
    4. DIncorrect. Length is a quality preference, well suited to instructions and examples.
    5. EIncorrect. Nice to have; skipping it once is not a compliance event.
  4. Question 4

    A customer writes: “My order is late, I was charged twice, and I need to change my delivery address.” The agent refunds the duplicate charge and closes the conversation. The other two issues are never addressed.

    What design change best prevents this?

    1. ADecompose the message into items, handle each, then send one reply.
    2. BEscalate every message that mentions more than one problem to a human.
    3. CAsk the customer to send each problem in a separate conversation.
    4. DRaise max_tokens so the agent has room to write a longer reply.
    Show answer and reasoning
    1. ACorrect. Treating the message as one problem let the most prominent issue crowd out the rest.
    2. BIncorrect. Over-escalation is expensive and unnecessary; these issues are all within the agent's scope.
    3. CIncorrect. Pushes the agent's job onto the customer and hurts the experience.
    4. DIncorrect. The reply was not truncated; the agent never investigated the other items.

Sources

Drafted with AI assistance and checked against the sources above; expert review is in progress. Spotted an error? Tell us and it gets fixed, dated and listed on how this is written.