Skip to content

    AI Architect Case Files

    Case: Fraud Investigation Workflow as a Saga

    A bank's AI-assisted fraud investigation left cards on hold with no case when one step failed. A saga with compensating actions and an outbox fixed it.

    By Published 8 min read

    • ai-architect
    • case-file
    • industry-financial-services
    • pattern-saga
    • failure-partial-failure
    • kind-composite
    Share

    Composite scenario, not a real company. Assembled from common industry patterns; every number is illustrative and its assumptions are listed at the end.

    This case belongs to Multi-agent and event-driven AI architecture.

    Context

    • The fraud operations team of a retail bank investigates flagged card transactions, about 600 a day.
    • An investigation has six parts: collect evidence from three internal systems, write a summary with a recommended action, place a temporary hold on the card, open a case, text the customer, and wait for an investigator to confirm fraud (block the card, order a replacement) or clear it (release the hold).
    • Analysts take about 25 minutes per alert by hand. The team wants a model to write the summary and a workflow to run the rest.

    Problem statement

    The pilot ran the steps as one agent loop in the order hold, text message, open case. When the case system timed out after the hold and the text, the card was held, the customer had been told so, and no case existed. No investigator ever saw it.

    Measure Value
    Runs that hit this About 0.5%: 600 x 0.005 = 3 a day
    Time unnoticed About 2.5 days each
    Cards held with no case at any moment 3 x 2.5 = 7.5
    Goal Every run ends completed or fully undone; any run that cannot be undone is visible to a person within 5 minutes

    Constraints

    • The card platform and the case system are separate services reached only through APIs; no transaction spans them.
    • A text message cannot be unsent, and a temporary hold may last at most 72 hours under the bank's policy.
    • A person decides whether fraud is confirmed, never the model.
    • A retried step must not hold or block twice.

    Why the traditional approach fell short

    Approach Why it fell short
    Manual runbook Progress lives in a head and a ticket note; an interruption leaves the half-done state above
    Fixed workflow engine Reliable, but leaves the slowest part, the evidence summary, to people: descriptors, device data and call notes are unstructured
    Rules-based fraud scoring Flags the transaction, assembles no case
    The pilot's agent loop Remembered what it had done only in its prompt, which is gone when the process dies

    Options considered

    Option Idea Verdict
    A. Manual checklist (non-AI) Analysts follow a runbook in the case tool Kept as the fallback and the manual queue
    B. Agent loop with tools, no persisted state The model decides each next step Rejected: nothing owns recovery; the model can skip or repeat a step
    C. Saga orchestrator, model only for the summary Code runs the steps, stores state after each, and undoes completed steps if a later one fails Accepted
    D. Distributed transaction across both systems Two-phase commit Rejected: the services expose only APIs, and a human wait of hours cannot sit inside a transaction

    The default is C: more code than B, but a vanished investigation becomes a recorded failure.

    Solution architecture

    Figure 1. Components of the investigation saga

    Components of the fraud investigation sagaEvent bus to Orchestrator (alert); Orchestrator to Document store (one transaction); Orchestrator to Approval service (request); Approval service to Orchestrator (answer); Orchestrator to Model gateway; Model gateway to LLM provider; Orchestrator to Tool server; Orchestrator to Tool server; Orchestrator to Tool server; Orchestrator to Trace store (traces)Event bus: fraud alertsEvent busfraud alertsDocument store: state + outboxDocument storestate + outboxApproval serviceApprovalserviceOrchestrator: sagaOrchestratorsagaTrace storeTrace storeModel gatewayModel gatewayLLM providerLLM providerTool server: card platformTool servercard platformTool server: case systemTool servercase systemTool server: customer messagingTool servercustomermessagingalertone transactionrequestanswertraces

    How to read this: the Orchestrator is the only box that talks to everything, the model has no line to any tool server, and the dotted line is observability.

    Figure 2. Runtime path with a failed case step and its compensation

    sequenceDiagram accTitle: Investigation saga with compensation accDescr: The Orchestrator gathers evidence, asks the model for a summary, checks the cited transaction ids, places a hold, then tries to open a case. If the case step fails after its retries the Orchestrator releases the hold, records the saga as compensated and sends the alert to the manual queue. If it succeeds the Orchestrator notifies the customer, asks the investigator for a decision and applies it. autonumber participant O as Orchestrator participant D as Document store participant M as Model gateway participant T as Tool server participant A as Approval service O->>T: gather evidence, read only O->>M: summarise evidence and propose an action M-->>O: summary citing transaction ids Note over O: Decision - every cited id must exist in the evidence O->>D: save state HOLD_PENDING and the hold command O->>T: place hold, key INV-77-hold T-->>O: hold placed O->>D: save state HOLD_PLACED O->>T: open case, key INV-77-case alt case opened T-->>O: case id O->>D: save state CASE_OPEN O->>T: notify customer, key INV-77-notify O->>A: request decision with summary A-->>O: investigator decision alt fraud confirmed O->>T: block card and order replacement else cleared O->>T: release hold and close case end else case step fails after retries Note over O: Decision - undo completed steps in reverse order O->>T: release hold, key INV-77-hold-undo O->>D: save state COMPENSATED O->>A: send to manual queue with the reason end

    How to read this: each tool call carries a key so a retry cannot repeat it, the first alt branch is the forward path, and the second is the undo path.

    How AI solved it, step by step

    Step through one alert, then switch to "Without the fix" to see the pilot's order.

    Investigation INV-77, end to end (interactive when JavaScript is on)

    As designed

    1. Start. An alert reaches the Event bus. The Orchestrator creates investigation INV-77 and stores STARTED.
    2. Evidence. It reads evidence from the three systems with read-only tools.
    3. Summary. The model, which has no tools, summarises the evidence and recommends an action, citing transaction ids.
    4. Check the ids. The Orchestrator checks that every cited id exists in the evidence. A summary citing a missing id is rejected and the case goes to the manual queue.
    5. Hold. It stores HOLD_PENDING and the hold command in one transaction, places the hold with key INV-77-hold, records HOLD_PLACED.
    6. Open the case. It opens the case with key INV-77-case. This is the step most likely to fail, so it comes before anything irreversible.
    7. If the case step fails. After three tries the Orchestrator releases the hold, records COMPENSATED and puts the alert in the manual queue.
    8. If it succeeds. With a case in place, the Orchestrator sends the text and asks the Approval service for a decision.
    9. Decision. The investigator decides. The Orchestrator applies it (block and replace, or release and close).

    Without the fix

    1. Hold. The agent loop places the temporary hold on the card first.
    2. Text message. It sends the text. The customer is told the card is on hold, and that cannot be unsent.
    3. Case times out. The case system times out. No case exists, and the loop's progress was only in its prompt, which is gone.
    4. Nobody knows. The card stays held with no case. No investigator ever sees it; about 2.5 days pass.

    The model made one decision: what to recommend. Code owns every state transition.

    Under the hood

    The microservices.io pattern page defines a saga as a reliably coordinated sequence of local transactions, where completed steps are undone by compensating transactions if the saga fails. In the orchestration style an orchestrator tells the participants which local transactions to execute, as in Figure 2.

    Cost the page lists What the design does
    No automatic rollback, so compensating transactions must be designed An undo for every step that has one; the hold's undo is release
    No isolation between concurrent sagas One active investigation per card
    A service must update its database and publish a message atomically without a distributed transaction Transactional outbox: the message is stored in the same transaction as the business change and a relay sends it

    The relay might publish a message more than once, so consumers must be idempotent: hence the keys. Figure 3 is the state machine the store holds.

    Figure 3. Saga states

    stateDiagram-v2 accTitle: Investigation saga states accDescr: A saga moves from started to evidence gathered, hold placed, case open, customer notified and awaiting decision, then resolved. A failure after the hold moves it to compensating, then compensated, or to needs human if the undo itself fails. If no decision arrives in 48 hours it is escalated. [*] --> Started Started --> EvidenceGathered EvidenceGathered --> HoldPlaced HoldPlaced --> CaseOpen HoldPlaced --> Compensating: case step failed CaseOpen --> AwaitingDecision: customer notified AwaitingDecision --> Resolved: decision applied AwaitingDecision --> Escalated: no decision in 48 hours Escalated --> Resolved: supervisor decides Compensating --> Compensated: hold released Compensating --> NeedsHuman: undo failed after retries Compensated --> [*] Resolved --> [*]

    How to read this: the right-hand column is the forward path, the two compensation states catch failures, and NeedsHuman is the only state that raises an alert for a stuck undo.

    See Under the hood: Sagas and compensating actions.

    What went wrong / failure modes

    Failure What the design does
    The undo fails (the release call times out) Retry with backoff, then NeedsHuman and an alert; never silently stays in Compensating
    The Orchestrator crashes mid-step On restart it reads the last stored state and resends the command with the same key, so the hold is not placed twice
    Two alerts on one card One active investigation per card; a second alert attaches to it
    The text message cannot be undone It is sent only after the case exists; if the case later proves wrong, the compensation is a correction message
    A made-up transaction id in the summary The id check rejects it
    Instructions hidden in free text Customer notes and merchant names are untrusted; the model has no tools, so it can only write a summary a person reads
    No decision arrives After 48 hours the saga escalates to a supervisor; the 72-hour hold limit still applies

    Results

    These are illustrative targets, not measurements.

    Measure Before After
    Cards held with no case Standing 3 x 2.5 = 7.5 About 3 x (5 / 1,440) = 0.01 on average: failed runs are undone within minutes; stuck undos raise NeedsHuman alerts
    Analyst time per alert 25 minutes 8 minutes
    Analyst time moved to decisions None 600 x 17 = 10,200 minutes, or 170 hours a day

    Tradeoffs and when NOT to use this approach

    • Writing a compensating action per step is real work, and some steps (a message, a payment) have none. Put irreversible steps last.
    • State and outbox storage add a dependency. Compensation gives eventual consistency, not isolation: a hold may be visible for minutes before it is undone.
    • What to do when no decision arrives is a policy choice: auto-releasing a hold protects customers, escalating protects against fraud.
    • With one external side effect, a saga is overkill; retry with an idempotency key.

    Design rules extracted

    1. Run multi-step actions as a saga: persist state after each step and define an undo for every step that has one.
    2. Put steps that cannot be undone last, after every step that can fail.
    3. Write state and the next command in one transaction, publish through an outbox, and give each command a key.
    4. A failed undo is an alert state, never a silent one.
    5. The model summarises and recommends; code owns transitions, and a person owns the irreversible decision.

    Assumptions

    • 600 alerts a day, a 0.5% partial-failure rate and 2.5 days before a customer calls are invented: 600 x 0.005 = 3 a day, 3 x 2.5 = 7.5 cards.
    • Compensation within 5 minutes: 3 x 5 / 1,440 = 0.0104 cards on average (1,440 minutes in a day).
    • The 25-minute and 8-minute analyst times are illustrative: 600 x (25 - 8) = 10,200 minutes = 170 hours.
    • Three tries, the 48-hour escalation and the 72-hour hold policy are invented settings.
    • The saga and outbox statements follow the microservices.io pattern pages, read on 2026-10-21; the bank, its systems and all figures are invented.

    Last verified: 2026-10-22

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments