{
  "id": 15253325,
  "title": "Finding the Bugs I Built an AI Agent to Prevent: Building Deterministic Guardrails with LangGraph & Python",
  "url": "https://urgent.news/2026/10/17/finding-the-bugs-i-built-an-ai-agent-to-prevent-building",
  "topic": "ai",
  "section": "AI",
  "published": "2026-10-17T18:28:21.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/emadaed/finding-the-bugs-i-built-an-ai-agent-to-prevent-building-deterministic-guardrails-with-langgraph--agf"
  },
  "original_language": "en",
  "account": "Detecting and preventing bugs built by an AI agent required creating deterministic guardrails, according to engineer Muhammad Ahmad. During six rounds of adversarial testing, multiple critical bugs emerged in the local AI agent, Ahmad-AI. The Ghost Row Bug appeared when querying a table with no matching rows, causing the agent to invent fake item IDs and stock levels. The Regex Mismatch bug occurred when the agent cited the Quran verse 5:51, despite the system prompt expecting a different format. To address these issues, Ahmad implemented a deterministic backstop in Python that overrides the model's prose if certain failure patterns are detected. This approach allowed for a whitelist of pre-verified citations and prevented the agent from stating specific data claims without verification. The engineer also emphasized the importance of code over additional instructions, an evaluation harness to ensure automation doesn't hide regressions, and distinguishing between transient and permanent errors.",
  "summary": "`` A real debugging log: fabrication bugs, deployment gaps, and false test passes found and closed across 6 rounds of adversarial testing. System prompts are a leash, not a lobotomy. A system prompt can be ignored, misread, or drift under pressure. Deterministic code cannot. When I built Ahmad-AI — a local AI agent using LangGraph, Python, and Ollama with access to live SQL databases and Islamic…",
  "key_points": [
    "Engineer Muhammad Ahmad created deterministic guardrails to prevent AI agent bugs.",
    "Ghost Row Bug and Regex Mismatch bugs discovered during adversarial testing.",
    "Deterministic backstop in Python overrides model output for detected failure patterns."
  ],
  "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."
}