{"slug": "why-your-ai-release-notes-hallucinate-the-why-vs-what-problem-in-git-history", "title": "Why Your AI Release Notes Hallucinate: The \"Why vs What\" Problem in Git History", "summary": "A developer re-engineered an LLM-based changelog pipeline after a raw git diff fed to a model produced fabricated release notes, claiming a memory-leak hotfix was a JSON serialization optimization. The rebuilt @necoz-oss/changelog-bot resolves GitHub closing keywords to pull linked issue context as ground truth, caps issue-fetch concurrency to avoid API rate limits, sanitizes noisy stack traces, and falls back to heuristic summaries when the API degrades.", "body_md": "I once deployed an automated release pipeline that piped raw `git diff` outputs straight into an LLM prompt. Two hours later, our generated release notes claimed that version `1.4.0` \"optimized JSON payload serialization for low-latency clients.\"\n\nIn reality, the underlying commit was an emergency patch for a memory leak that crashed Kubernetes pods under peak traffic. The code diff happened to delete several buffer allocations, and the model fabricated an appealing performance feature out of thin air.\n\nThat incident exposed a fundamental blind spot in how engineering teams automate changelogs with AI.\n\nWhen we ask an LLM to read a git commit or unified diff, we are asking it to divine human intent from syntax changes.\n\nA diff tells you that `timeoutMs` changed from `5000` to `15000`. It does not tell you that downstream payment gateways began dropping socket handshakes during cloud provider migrations. Without grounding context, the model resolves the ambiguity by inventing the most statistically plausible narrative: \"improved network stability.\"\n\nThis becomes dangerous when breaking changes are involved. According to the [Conventional Commits v1.0.0 specification](https://www.conventionalcommits.org/en/v1.0.0/), breaking changes can reside inside commit message footers or body paragraphs. A naive diff parser summarizes the altered function signature, while completely erasing the migration path requested by the engineer.\n\nThe problem deepens as more code is authored by autonomous AI coding agents. Agent-generated pull requests often arrive with beautifully formatted markdown descriptions. When I analyzed hundreds of these descriptions, I identified three recurring archetypes:\n\nStandard summarization prompts routinely latch onto the **unsupported-plausible** archetype. The resulting changelog looks convincing to release managers, but distributes false technical claims to your users.\n\nTo stop LLMs from hallucinating reasons, I re-engineered the extraction pipeline in [@necoz-oss/changelog-bot](https://www.npmjs.com/package/@nyaomaru/changelog-bot) (hosted on [GitHub](https://github.com/necoz-oss/changelog-bot)). \n\nInstead of relying solely on PR descriptions or diffs, the engine tracks back to where the problem was originally defined: the linked GitHub issue. Under the [GitHub Issue Linking specification](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue), closing keywords establish verifiable causal links.\n\n```\n// Match GitHub closing keywords preceding an issue reference or URL.\n// See: https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue\nexport const CLOSING_KEYWORD_PATTERN =\n  /(?:\\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?))\\s*[:：]?\\s*(?:\\[[^\\]]+\\]\\((?<markdownUrl>https?:\\/\\/[^\\s)]+)\\)|(?<issueUrl>https?:\\/\\/[^\\s)]+\\/issues\\/(?<urlIssueNumber>\\d+)\\b)|(?:(?<repoPrefix>[\\w.-]+\\/[\\w.-]+)?#(?<issueNumber>\\d+)))/gi;\n\nexport function resolveLinkedIssueNumbers(\n  prBody: string,\n  repo: { owner: string; repo: string },\n): number[] {\n  const matches = Array.from(prBody.matchAll(CLOSING_KEYWORD_PATTERN));\n  const issueNumbers = matches\n    .map((match) => match.groups?.issueNumber || match.groups?.urlIssueNumber)\n    .filter(Boolean)\n    .map(Number);\n\n  return Array.from(new Set(issueNumbers)).slice(0, 2);\n}\n```\n\nMining issue context introduces network risk. To protect CI runners against [GitHub API rate limits](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api), I bounded issue resolution concurrency and implemented strict sanitization. Noisy stack traces and debug dumps are stripped before candidate snippets reach the evaluation step, falling back gracefully to heuristic summaries if the API degrades.\n\nThe differences between an ad-hoc AI prompt and a ground-truth pipeline determine whether your changelog can be trusted in production.\n\n| Architectural Dimension | Naive Git Diff + LLM Prompt | Grounded Pipeline (ChangelogBot Approach) | \n|---|---|---|\n| **Primary Context Source** | Raw lines added and deleted | Linked issue bodies and closing keywords | \n| **Noise Filtering** | Ingests raw stack traces and AST churn | Sanitizes logs; bounds concurrent API requests | \n| **Hallucination Defense** | None (pure probability generation) | Counterfactual calibration and archetype scoring | \n| **Delivery Decoupling** | Hardcoded to create PRs or write files | Unix-compliant output ( `stdout` ,`file` ,`pull-request` ) | \n| **API Failure Fallback** | Hard CI build failure | Graceful degradation to deterministic heuristics | \n\nHow do you verify whether an extractor captures genuine rationale rather than plausible fluff? You cannot rely on human intuition when reviewing hundreds of releases.\n\nI built a counterfactual test corpus containing matched case families. For each pull request, the benchmark provides:\n\nBy tracking the False Positive Rate (FPR) when the extractor is presented with decoy options, I could mathematically penalize models that pick convincing-sounding lies. If an extraction engine cannot consistently reject a counterfactual candidate, it has no place in an automated production release pipeline.\n\nThe final anti-pattern I eliminated was coupling changelog generation to write-heavy side effects.\n\nTraditional tools halt your CI pipeline if you do not grant them a write-scoped GitHub personal access token to open a pull request. I restructured `changelog-bot` so that changelog generation is completely decoupled from delivery:\n\n`--output stdout`: Emits clean, streamable release markdown to standard out, redirecting all telemetry and diagnostic logs strictly to `stderr`.`--output file`: Appends updates locally to `CHANGELOG.md` with zero network overhead.`--output pull-request`: Reserves write token requirements strictly for automated PR creation.\nThis separation means developers can test release notes locally or pipe them into custom release scripts without provisioning repository write access.\n\n`stdout` without mandating write permissions.\nWhat failure modes have you encountered when feeding git logs or PR descriptions into LLMs?\n\nIf you found this article helpful, let's connect!", "url": "https://wpnews.pro/news/why-your-ai-release-notes-hallucinate-the-why-vs-what-problem-in-git-history", "canonical_source": "https://dev.to/necoz/why-your-ai-release-notes-hallucinate-the-why-vs-what-problem-in-git-history-5ch0", "published_at": "2026-11-24 16:30:00+00:00", "updated_at": "2026-11-24 16:47:42.801613+00:00", "lang": "en", "topics": ["ai-tools", "large-language-models", "developer-tools", "ai-agents"], "entities": ["@necoz-oss/changelog-bot", "GitHub", "Conventional Commits", "Kubernetes"], "also_reported_by": [], "takeaway": "Grounding changelog generation in linked GitHub issues resolved via closing keywords, rather than raw diffs or PR descriptions, prevents LLMs from inventing plausible-sounding features out of unrelated code changes.", "recommendation": {"advice": "Resolve linked issues from PR closing keywords and feed that context to the changelog model instead of raw diffs; cap issue-fetch concurrency and fall back to heuristics when the GitHub API degrades.", "playbook": "output-verification", "playbook_url": "https://wpnews.pro/playbooks/output-verification"}, "alternates": {"html": "https://wpnews.pro/news/why-your-ai-release-notes-hallucinate-the-why-vs-what-problem-in-git-history", "markdown": "https://wpnews.pro/news/why-your-ai-release-notes-hallucinate-the-why-vs-what-problem-in-git-history.md", "text": "https://wpnews.pro/news/why-your-ai-release-notes-hallucinate-the-why-vs-what-problem-in-git-history.txt", "jsonld": "https://wpnews.pro/news/why-your-ai-release-notes-hallucinate-the-why-vs-what-problem-in-git-history.jsonld"}}