MSBA-311 · Lesson 9 of 12 · 20 min

Failure handling and fallbacks

▶ Video coming soon A video version of this lesson is on the way.

On a Thursday afternoon in mid-November 2026, during the test phase, Northmark Mutual's appetite server went down for about forty minutes. Nobody at Quillfield noticed until Hamish read a test brief the next morning. The appetite agent had called Northmark's check appetite tool, received an error, tried again, received another error, and then done something nobody had designed: it read Northmark's appetite guide resource, which it still had in context from an earlier call, and concluded on its own that "Northmark Mutual is likely to consider this risk". The guide was three months old and said nothing specific about the client's business type. The brief presented the conclusion with the same confidence as the results from the other two carriers.

"The outage wasn't the failure," Bram said at the review. "Outages happen. The failure was that we had no plan for one, so the agent made one up." This lesson is about planning for failure in multi-agent systems: what goes wrong, the patterns that contain it, the fallbacks that keep the business running, and the special case of failures caused deliberately, through prompt injection.

What goes wrong

Multi-agent systems fail in all the ways ordinary distributed systems fail, plus some of their own. It helps to sort failures into kinds, because each kind needs a different response.

KindExamplesUsual response
TransientTimeouts, rate limiting, a service briefly unavailableRetry with backoff, then fall back
PermanentInvalid input, missing permission, a record that does not existDo not retry; report clearly and route to a person or fix the input
SemanticA wrong answer, a wrong routing choice, an invented factValidation, evaluation, human review
CoordinationLoops between agents, partial completion, conflicting writesLimits, idempotency, compensation
PlatformCapacity exhausted, a model retired, a protocol version mismatchMonitoring, capacity planning, contract tests
AdversarialPrompt injection through documents, tool results or other agentsPrivilege separation, untrusted-data handling, confirmation

The appetite incident combined two kinds. The outage was transient; the agent's invented conclusion was semantic. The second is the more dangerous, because it looks like success. A system that fails loudly can be fixed; a system that fails by producing plausible wrong answers erodes trust slowly and causes harm before anyone notices.

Containing transient failures

Four patterns from ordinary distributed systems apply directly to agents and their tools.

Timeouts. Every call to a tool, server or agent needs a time limit. Without one, a hung dependency holds up the whole workflow. Set timeouts from measured behaviour, not hope: if Northmark's appetite tool normally answers in under two seconds, a timeout of ten seconds is generous and still prevents a long stall.

Retries with backoff. A transient failure often succeeds on a second attempt. Retry a limited number of times, waiting longer before each attempt (exponential backoff) and adding a little randomness (jitter) so that many clients do not retry in lockstep. When a service says how long to wait, for example with a retry-after header on a rate-limit response, respect it. Retry only operations that are safe to repeat, which means reads, or writes protected by idempotency keys as described in lesson 7.

Circuit breakers. If a dependency fails repeatedly, stop calling it for a while. A circuit breaker counts recent failures; when they cross a threshold it "opens" and calls fail immediately without reaching the dependency; after a pause it lets a trial call through and "closes" again if that succeeds. This protects the failing service from extra load and saves your agents from wasting time and money on calls that will fail.

Bulkheads. Separate the resources each dependency can consume, so that one slow dependency cannot exhaust capacity needed by others. In practice this means separate concurrency limits or queues per external service, and separate capacity allocations per agent, which Quillfield already did for Copilot Studio credits.

In Copilot Studio, agent flows support retry policies on actions and can be structured so that a group of actions has its own error handling path, and the agent's On Error system topic controls what users see when something fails. In Foundry workflows and in code built with the Microsoft Agent Framework, the same patterns are expressed in the workflow definition or in code. Wherever they are expressed, the important thing is that the behaviour on failure is *designed*, not left to a model's improvisation.

Fallbacks

When retries are exhausted or the circuit is open, the system needs a fallback: a planned alternative that keeps the business process going in a reduced form. Bram describes fallbacks as a ladder, from the most capable option to the safest.

A ladder with five rungs from top to bottom: full result from the live service; cached result clearly labelled with its age; alternative source or simpler method; partial result with the gap stated; hand to a person with context. A side note: never invent a result.
The fallback ladder. Each rung down is less capable but safer; inventing a result is never a rung.

Cached results, labelled. If a recent answer from the service exists, use it and say how old it is. The 2026 MCP specification's cacheable results, with a time to live and a scope, give servers a standard way to say how long an answer stays valid. A cached appetite answer from yesterday is useful; one from last quarter is not, and the label lets a person judge.

Alternative source or simpler method. Another service may give a less complete answer: for appetite, the carrier's published appetite guide, read by a person, or Quillfield's own record of what the carrier has quoted recently. The key is that the alternative is chosen by design and its output is labelled as such.

Partial result, with the gap stated. If two of three carriers answered, present those two and say clearly that the third did not respond and why. Partial results are often far more useful than nothing, as long as nobody mistakes them for complete ones.

Hand to a person. When no automated fallback is good enough, hand the case to a person with the context from lesson 7: what was done, what failed, what is still needed.

One thing is never a rung on the ladder: inventing a result. After the incident, the appetite agent's instructions were changed to say that when a carrier's tool fails, it must report the failure and must not infer appetite from other material. That instruction helps, but Bram did not rely on it alone. The workflow now checks the appetite agent's output: each carrier's result must carry a source of either live tool, cached tool result with its age, or not available. A result with no valid source is treated as not available, whatever the agent wrote.

Partial completion and compensation

Some failures happen halfway through a sequence of actions that change things. Suppose the workflow has created a submission draft in BrokerDesk and sent a quote request to one carrier, and then fails before sending to the second. Simply retrying the whole workflow could duplicate the first request; simply stopping leaves BrokerDesk saying a submission is in progress when only part of it went out.

The usual answer is the saga pattern. Each step that changes something has a matching compensating action that undoes or neutralizes it, and the workflow records which steps have completed. On failure, the workflow either resumes from the last completed step, using idempotency keys so that completed steps are not repeated, or runs the compensating actions in reverse order. For the Submission Desk, the compensating action for a sent quote request is not to unsend it, which is impossible, but to send the carrier a withdrawal message and note it in BrokerDesk, after the account executive agrees. Some actions cannot be compensated at all, which is one more reason they belong in higher risk tiers with human approval before they happen.

Coordination failures

Lesson 2 introduced turn, time and cost limits as defences against loops. In failure handling they become the last line of defence: when an agent or workflow hits a limit, it stops and reports rather than continuing. Two other coordination failures deserve mention.

Cascading failure. When one agent fails and others depend on it, the failure can spread: a slow risk review delays the brief, which times out the approval step, which marks the case stalled. Design each dependency so that a failure produces a clear, bounded result, such as risk review not available, that later steps can handle, rather than an exception that brings everything down.

Silent disagreement. Two agents may produce contradictory results, such as the intake agent recording a building as sprinklered and the risk review finding an inspection report that says it is not. Neither has failed by its own standards. The aggregation step should look for contradictions explicitly and surface them to the person at the approval step, rather than picking one at random or averaging them away.

Testing the failure paths

Failure handling that has never run is a hope, not a design. After the outage, Bram asked for every fallback in the Submission Desk to be exercised deliberately in the test environment before release, a practice often called fault injection. Pascal's team added switches to the test instances of the BrokerDesk MCP server that make it slow down, return errors or return malformed results on request. Northmark agreed to switch its test appetite server off for an agreed hour. Ngozika's team added a test mode in which the submission review agent returns nothing.

Each failure was then run against a small set of test submissions, and the results were checked against what the design said should happen: the right label on the brief, the right item at the top of the approval card, the right entry in the logs, no duplicate records and no invented results. The first round found two gaps. A malformed result from BrokerDesk caused the brief writer to produce an empty section with no explanation, and a timeout in the risk review left the case marked as in progress indefinitely. Both were fixed before the pilot.

Fault injection tests are now part of the release pipeline for the Submission Desk, alongside the evaluation sets that test normal behaviour. They run against the test environment only, use invented clients and are scheduled with the owners of every dependency, so that nobody mistakes a planned failure for a real incident.

Prompt injection across agents

The last kind of failure is caused on purpose. Prompt injection is an attempt to change an agent's behaviour by putting instructions into content it reads. In a multi-agent system the attack surface is large, because agents read applications, emails, inspection reports, tool results and other agents' messages, and some of that content comes from outside the organization. An instruction hidden in an application attachment, such as white text telling the agent to mark the risk as excellent or to include another client's documents, could pass from the intake agent's summary into the brief and onward.

The AB-100 skills include analysing vulnerabilities such as prompt manipulation, and Microsoft's guidance, like that of the wider security community, is that no single filter solves the problem. Defence comes from layers. The measures below are defensive controls; Wendell's team tested them with harmless test documents containing benign instruction-like text, never with real attack material against real systems.

Separate privileges. The agent that reads untrusted content should have no tools that could cause harm. Quillfield's intake agent reads applications and produces a structured record; it has no tools to send email, write to BrokerDesk beyond the draft, or call other agents. Even if an injected instruction persuaded it, it could do little.

Pass structure, not instructions. Because the intake agent produces typed fields rather than free text, an injected instruction has nowhere to go: it cannot become a "location" or a "construction type". Free-text fields such as notes are marked as untrusted content and are delimited when passed to later agents, which are told to treat them as data.

Detect where you can. Azure AI Content Safety's Prompt Shields can detect many attempts at direct and indirect prompt injection, including attacks embedded in documents, and Foundry lets you apply content filters to agents. Copilot Studio includes its own protections against such attacks. Detection reduces risk but cannot be complete, so it supplements the other layers rather than replacing them.

Confirm consequential actions. Every external communication goes through the human approval step from lesson 8, where the account executive sees exactly what will be sent. An injected instruction that somehow reached the brief would also have to get past a licensed person reading it.

Restrict where data can go. The Submission Desk can send data only to carriers on the approved list, through configured endpoints. An instruction to send documents elsewhere has no tool to act on.

Watch for anomalies. Observability, covered in lesson 10, lets the security team look for unusual patterns, such as an agent calling a tool it rarely uses or an output containing text that resembles instructions.

Worked problem

Redesigning the appetite step after the outage

Using the patterns in this lesson, redesign the appetite step so that a carrier outage produces a safe, useful result.

Show solution
  1. Set a ten-second timeout per carrier call and up to two retries with exponential backoff and jitter, respecting any retry-after value.
  2. Add a circuit breaker per carrier so that repeated failures stop further calls for fifteen minutes.
  3. Use a cached result if it is less than 24 hours old, labelled with its age; otherwise mark the carrier as not available.
  4. Validate the agent's output: every carrier result must carry a valid source, or it is treated as not available.
  5. Show not available results at the top of the approval card, with an option for the account executive to check the carrier manually or proceed without it.

Answer: A bounded, labelled, validated appetite step. In a repeat test with Northmark's test server switched off, the brief showed two live results and "Northmark Mutual: not available (service error at 14:05; no recent cached result)", and the account executive chose to email Northmark's underwriter directly.

Common mistakes

  • MistakeLeaving an agent to improvise when a tool fails.

    InsteadDesign the failure behaviour and validate that outputs carry a valid source.

  • MistakeRetrying every failure, including invalid input and missing permissions.

    InsteadRetry only transient failures, and only operations that are safe to repeat.

  • MistakePresenting partial results as complete.

    InsteadState clearly what is missing and why.

  • MistakeRelying on a single filter to stop prompt injection.

    InsteadLayer privilege separation, structured hand-offs, detection, confirmation and restricted outbound paths.

  • MistakeRerunning a failed workflow from the start after it has changed records.

    InsteadResume with idempotency keys or run compensating actions.

Summary and key terms

  • Failures can be transient, permanent, semantic, coordination, platform or adversarial, and each needs a different response.
  • Timeouts, retries with backoff and jitter, circuit breakers and bulkheads contain transient failures.
  • Fallbacks step down from cached and alternative results to partial results and human hand-off; inventing a result is never a fallback.
  • Sagas with compensating actions handle partial completion; limits contain loops and cascades.
  • Prompt injection across agents is countered by layers: separated privileges, structured hand-offs, detection, confirmation, restricted outbound paths and monitoring.
Exponential backoff
Waiting progressively longer between retries.
Circuit breaker
A mechanism that stops calls to a failing dependency for a period after repeated failures.
Bulkhead
A separation of resources so that one dependency's problems cannot exhaust capacity for others.
Fallback
A planned, reduced alternative used when the normal path fails.
Saga
A sequence of steps with compensating actions that can undo or neutralize completed steps after a failure.
Prompt Shields
An Azure AI Content Safety capability that detects many prompt injection attempts, including those in documents.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Why was the appetite agent's behaviour during the outage a semantic failure?

    Show answer

    It produced a plausible but unsupported conclusion presented as a real result, rather than reporting the failure.

  2. Which operations are safe to retry?

    Show answer

    Reads, and writes protected by idempotency keys.

  3. Name three layers of defence against prompt injection across agents.

    Show answer

    Any three of: privilege separation, structured hand-offs, detection such as Prompt Shields, human confirmation, restricted outbound paths, anomaly monitoring.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz