{"slug": "we-built-a-bug-fixing-ai-agent-with-a-state-machine-not-just-a-better-prompt", "title": "We built a bug-fixing AI agent with a state machine, not just a better prompt", "summary": "A team's bug-fixing AI agent named Sherlock completed 13% of all company tasks over a recent 15-day window and finished 90 of its last 100 assigned tasks successfully, according to the team's writeup on DEV Community. The team attributes the reliability to a 10-stage state machine with two token-gated human approval checkpoints, disk-based state recovery via state.json, mandatory per-stage artifacts, and a self-review loop capped at 6 iterations. The team said the 90/100 figure depends on which tasks are routed to the agent and that reopen-rate data has not yet been published.", "body_md": "\"Our team rarely fixes routine bugs by hand anymore. A dedicated agent (we call him Sherlock) takes bugs straight from Slack, and over a recent 15-day window he completed 13% of all company tasks. Of his last 100 assigned tasks, 90 finished successfully.\n\nThe interesting part: that trust didn’t come from the model being smart. It came from making the workflow strict enough that being wrong is recoverable and visible.\n\nWhat actually made it work:\n\nA state machine, not a role prompt. “You are an expert engineer” prompts produce a different path every run. Sherlock follows 10 fixed stages and can’t skip ahead — even when the fix looks obvious. Diagnosis stage can’t touch product code. Period.\n\nTwo human gates with explicit tokens. First version had 7 approval checkpoints and our engineer became the bottleneck — approving fragments all day. We cut it to two: [START DEVELOPMENT] (allow code changes) and [SUBMIT FOR TESTING] (allow push/merge). “Looks good” and “continue” do not count as authorization — casual yes’s got misread too many times.\n\nEvery stage must produce an artifact. diagnosis.md, idea.md, plan.md, review-report.md. A chat message saying “diagnosis complete” has no authority. This killed the “I’m done” fibbing.\n\nInterrupted sessions recover from disk, not chat history. All state lives in state.json. If a session dies mid-run, the next run reloads and continues. We tried reconstructing from conversation history — the agent hallucinated progress.\n\nSelf-review with a hard cap. After implementing, the agent reviews its own diff “clean-room” — as an independent reviewer. If it finds blocking issues it patches and re-reviews, max 6 iterations, then it stops and escalates to a human. Without the cap it patched itself in circles forever.\n\nScreenshots at the decision point. For UI changes, before/after screenshots go directly in the conversation — not as file paths. A review I can do in 30 seconds gets approved correctly; one where I have to go dig through directories doesn’t.\n\nReal example: a “list not scrollable” bug went Slack → structured task → 14 min autonomous diagnosis → 3 decisions for human → approved → 37 min implementation → PR + preview URL + screenshots. Two human decisions total.\n\nFull writeup with the actual screenshots: [How to Build an AI Agent That Fixes Bugs Reliably: Practice in Sharkly - DEV Community]([How to Build an AI Agent That Fixes Bugs Reliably: Practice in Sharkly - DEV Community](https://dev.to/yukioikeda/how-to-build-an-ai-agent-that-fixes-bugs-reliably-practice-in-sharkly-o63))\n\nHappy to answer questions about the state machine design — and honest about the limits too: the 90/100 is conditional on what kinds of tasks get routed to the agent, and we haven’t published reopen-rate data yet (that’s the next thing we’re measuring).\n\n\" voici le template as tu vraiment respecter ca ?", "url": "https://wpnews.pro/news/we-built-a-bug-fixing-ai-agent-with-a-state-machine-not-just-a-better-prompt", "canonical_source": "https://discuss.huggingface.co/t/we-built-a-bug-fixing-ai-agent-with-a-state-machine-not-just-a-better-prompt/191768#post_1", "published_at": "2026-11-12 07:36:51+00:00", "updated_at": "2026-11-12 07:50:35.966340+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "artificial-intelligence"], "entities": ["Sherlock", "Sharkly", "Slack", "DEV Community"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/we-built-a-bug-fixing-ai-agent-with-a-state-machine-not-just-a-better-prompt", "markdown": "https://wpnews.pro/news/we-built-a-bug-fixing-ai-agent-with-a-state-machine-not-just-a-better-prompt.md", "text": "https://wpnews.pro/news/we-built-a-bug-fixing-ai-agent-with-a-state-machine-not-just-a-better-prompt.txt", "jsonld": "https://wpnews.pro/news/we-built-a-bug-fixing-ai-agent-with-a-state-machine-not-just-a-better-prompt.jsonld"}}