{
  "id": 2572232,
  "title": "The Ralph Loop: running coding agents for hours",
  "url": "https://urgent.news/2026/08/22/the-ralph-loop-running-coding-agents-for-hours",
  "topic": "ai",
  "section": "AI",
  "published": "2026-08-22T12:05:35.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/ghalex/the-ralph-loop-running-coding-agents-for-hours-3po2"
  },
  "original_language": "en",
  "account": "The concept known as the \"Ralph loop\" arises from the observation that when running coding agents on real tasks, the performance gradually degrades over time. Initially, the agent is sharp and efficient, but by the third hour, it begins re-reading previously examined files, contradicting its earlier decisions, and confidently fixing issues it created earlier. This degradation is primarily due to the context window filling up with stale information, leading to a situation where the agent's judgment deteriorates even before the context window is completely filled. This phenomenon is referred to as \"context rot\".\n\nTo address this issue, Geoffrey Huntley introduced the Ralph loop, named after Ralph Wiggum from The Simpsons, who is not the sharpest but never gives up. The technique involves running the agent with the same prompt in a fresh session repeatedly. Each iteration starts with a blank context, reads the plan file, selects the most important unfinished task, completes it, and writes the progress back to disk before terminating. The loop then restarts the process until all tasks are completed. The genius of this approach lies in its avoidance of keeping a single, long-lived session alive and instead embracing the value of a fresh context window for each unit of work. This design allows the agent to deliberately allocate the context window to one task and then discard the session, effectively preventing context degradation.\n\nThe primary problem that the Ralph loop solves is the \"context window is too small\" issue, rather than the context window filling up with irrelevant information. This approach enables the agent to perform tasks more efficiently while ensuring that each iteration starts with a clean slate, avoiding the accumulation of errors from previous iterations. The loop's simplicity, yet profound impact, has led to its successful application in building entire codebases overnight.",
  "summary": "Anyone who has run a coding agent on a real task — not a demo, a multi-hour grind through a milestone — has watched the same decay curve. The first hour is sharp. By the third, the agent is re-reading files it already read, contradicting decisions it made earlier, and confidently \"fixing\" things it broke twenty minutes ago. Nothing is wrong with the model. What's wrong is the session: the context…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 2,
    "also_reported_by": [
      {
        "outlet": "Dev.to",
        "title": "Two Hours Lost to a Silent 401: Submitting 12 iOS Apps to the App Store With No Human in the Loop (Part 1)",
        "url": "https://urgent.news/2026/08/21/two-hours-lost-to-a-silent-401-submitting-12-ios-apps-to-the-app",
        "published": "2026-08-21T05:00:09.000Z"
      }
    ]
  },
  "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."
}