{
  "id": 10188403,
  "title": "AWS Lambda Durable Functions and the Replay Bug in Human-in-the-Loop Agents",
  "url": "https://urgent.news/2026/09/27/aws-lambda-durable-functions-and-the-replay-bug-in-human-in-the-loop",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-27T09:59:05.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/aws-builders/aws-lambda-durable-functions-and-the-replay-bug-in-human-in-the-loop-agents-ki8"
  },
  "original_language": "en",
  "account": "AWS Lambda durable functions, introduced in late 2025, enable developers to create long-running, multi-step workflows within a single Lambda handler. This feature suspends the function for up to a year while waiting for human input or external events, eliminating the need for a separate state machine or task tokens. Durable functions simplify code structure by collapsing complex orchestration into regular top-to-bottom code using two primitives: context.step(...) to checkpoint a unit of work and context.wait_for_callback(...) to pause execution until an external callback.\n\nThe author built a human-in-the-loop agent workflow using AWS Lambda durable functions to propose an action, seek human approval, and execute if approved. The agent suspends the workflow, awaiting human approval, and resumes when the human decides. However, the author discovered a dangerous bug called \"replay\" that can lead to unexpected behavior. When the agent proposes an action outside a step, the function replays from the top upon resumption, executing the proposal again if the agent's output differs. This results in executing a different action than what the human approved.\n\nThe author demonstrated this issue with a mock agent that returns different actions each time it runs. In the unsafe version, where the agent proposal is outside a step, the human approved a refund, but the system executed an escalation instead, as the agent generated a different proposal on replay. Conversely, in the safe version, where the agent proposal is inside a step, the system executed the approved refund, as the checkpointed result maintained consistency.\n\nThis replay bug highlights the importance of understanding AWS Lambda durable functions' mechanics to avoid unexpected behavior in human-in-the-loop agent workflows. By properly structuring code within steps, developers can prevent such issues and ensure accurate execution of approved actions.",
  "summary": "Ciao 👋 Here is a sentence that should not be possible: my workflow executed an action a human explicitly did not approve. Not a different user's action, not a race condition, not a bug in my business logic. The human looked at the screen, saw \"refund,\" clicked approve, and the system went and did \"escalate\" instead. Nobody tampered with anything. The code looked correct. The culprit was a…",
  "key_points": [
    "AWS Lambda durable functions enable long-running workflows with human input.",
    "Replay bug causes unexpected behavior when agent proposal is outside a step.",
    "Properly structuring code within steps prevents replay bug issues."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}