DEV Community

Cover image for Why Your AI Release Notes Hallucinate: The "Why vs What" Problem in Git History
𝗝𝗼𝗵𝗻 for Necoz

Posted on AI-assisted

Why Your AI Release Notes Hallucinate: The "Why vs What" Problem in Git History

Comments suggest linking issues to trace reasoning

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."

In 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.

That incident exposed a fundamental blind spot in how engineering teams automate changelogs with AI.

Command line terminal displaying code logs

Commits Record the "What", Not the "Why"

When we ask an LLM to read a git commit or unified diff, we are asking it to divine human intent from syntax changes.

A 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."

This becomes dangerous when breaking changes are involved. According to the Conventional Commits v1.0.0 specification, 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.

The Agent PR Trap: Slick but Unsupported Rationales

The 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:

  1. Grounded intent: Accurately relays verifiable user and business motivations.
  2. Unsupported-plausible: A polished, convincing explanation that sounds authoritative but has zero backing in the actual issue or user bug report.
  3. Implementation-only: A dry walkthrough of AST changes without explaining user impact.

Standard 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.

Mining Ground Truth from Linked Issues

To stop LLMs from hallucinating reasons, I re-engineered the extraction pipeline in @necoz-oss/changelog-bot (hosted on GitHub).

Instead 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, closing keywords establish verifiable causal links.

// Match GitHub closing keywords preceding an issue reference or URL.
// See: https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue
export const CLOSING_KEYWORD_PATTERN =
  /(?:\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;

export function resolveLinkedIssueNumbers(
  prBody: string,
  repo: { owner: string; repo: string },
): number[] {
  const matches = Array.from(prBody.matchAll(CLOSING_KEYWORD_PATTERN));
  const issueNumbers = matches
    .map((match) => match.groups?.issueNumber || match.groups?.urlIssueNumber)
    .filter(Boolean)
    .map(Number);

  return Array.from(new Set(issueNumbers)).slice(0, 2);
}
Enter fullscreen mode Exit fullscreen mode

Mining issue context introduces network risk. To protect CI runners against GitHub API rate limits, 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.

Modern software development code editor interface

Naive Diff Summarizers vs. Grounded Release Pipelines

The differences between an ad-hoc AI prompt and a ground-truth pipeline determine whether your changelog can be trusted in production.

Architectural Dimension Naive Git Diff + LLM Prompt Grounded Pipeline (ChangelogBot Approach)
Primary Context Source Raw lines added and deleted Linked issue bodies and closing keywords
Noise Filtering Ingests raw stack traces and AST churn Sanitizes logs; bounds concurrent API requests
Hallucination Defense None (pure probability generation) Counterfactual calibration and archetype scoring
Delivery Decoupling Hardcoded to create PRs or write files Unix-compliant output (stdout, file, pull-request)
API Failure Fallback Hard CI build failure Graceful degradation to deterministic heuristics

Benchmarking with Counterfactual Evaluation

How do you verify whether an extractor captures genuine rationale rather than plausible fluff? You cannot rely on human intuition when reviewing hundreds of releases.

I built a counterfactual test corpus containing matched case families. For each pull request, the benchmark provides:

  • A verified rationale grounded in real user reports.
  • Counterfactual decoy rationales (plausible statements that describe unrelated features or false root causes).

By 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.

Decoupling Delivery for Safe CI Workflows

The final anti-pattern I eliminated was coupling changelog generation to write-heavy side effects.

Traditional 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:

  • --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.

This separation means developers can test release notes locally or pipe them into custom release scripts without provisioning repository write access.

The Takeaway

  1. Stop summarizing diffs: Diffs tell you what changed in syntax; linked issues explain why the change mattered to users.
  2. Benchmark against decoys: Use counterfactual test sets to quantify whether your LLM can reject plausible but ungrounded claims.
  3. Keep delivery decoupled: Ensure your changelog generator can emit pure markdown to stdout without mandating write permissions.

What failure modes have you encountered when feeding git logs or PR descriptions into LLMs?


Connect with Me

If you found this article helpful, let's connect!

johnnylemonny GitHub Banner

Top comments (10)

Collapse
 
nyaomaru profile image
nyaomaru Necoz •

I really like the “What vs Why” framing here! 😸

That gap is exactly one of the hardest parts of generating release notes with AI.

A diff can give you plenty of implementation detail, but if the reason isn’t actually present in the evidence, a model can very easily fill in the blank with something that merely sounds convincing.

I’m especially happy to see the linked-issue evidence and counterfactual evaluation highlighted.

For changelog-bot, the goal isn’t just to generate nicer prose, it’s to make sure the WHY we surface is actually supported by something we can point back to.

Thanks for digging into the project so deeply! 💚

Collapse
 
johnnylemonny profile image
𝗝𝗼𝗵𝗻 Necoz •

Thanks so much for the kind words and for the work on changelog-bot! Framing it around "What vs. Why" really clicked once I saw how easily a plausible-sounding summary can mask the real reason behind a change. Grounding claims in linked issues and testing against counterfactual decoys makes the whole pipeline much more trustworthy in practice. Really appreciate you taking the time to read and share your thoughts.

Collapse
 
neithergalax profile image
neitherGalax Necoz •

This is interesting example of the difference between what machines can see and what humans understand. As the OS contributors, we know there's more to a code change than just the diff. Issues and PR discussions often tell the story behind it. But that also depends on how well we document our thoughts and decisions. AI can certainly connect the dots, but I still think human review matters.

Collapse
 
johnnylemonny profile image
𝗝𝗼𝗵𝗻 Necoz •

Spot on, especially about how much depends on the context we actually write down in issues and PR threads. AI is great at connecting dots across those artifacts, but when context is missing or implicit, human review is still essential to catch what the code alone cannot explain. Thanks for sharing that perspective.

Collapse
 
gautamtalksdev profile image
Gautam K •

The memory leak patch turned into a 'JSON serialization optimisation' is a perfect example. The diff showed deleted buffers, so the model invented a reason that fit. Linking the issue is the fix because the issue holds the why and the diff only holds the what. Do you block generation entirely when a commit has no linked issue?

Collapse
 
johnnylemonny profile image
𝗝𝗼𝗵𝗻 Necoz •

No, it does not block generation entirely. Unlinked changes fall back to deterministic heuristics or lighter summaries without inventing intent, while keeping ungrounded items clearly separated from issue-backed claims.

Collapse
 
reidmarlow profile image
Reid Marlow •

The two-issue limit makes provenance especially useful: if a PR closes three issues, a release note can end up with only part of the reason. I'd keep the issue URLs beside each generated claim and flag uncited rationale for review. That also makes the API-failure fallback visible instead of presenting a heuristic as sourced intent.

Collapse
 
johnnylemonny profile image
𝗝𝗼𝗵𝗻 Necoz •

Great catch on the two-issue cap and provenance tracking. Attaching explicit issue URLs to individual claims, surfacing ungrounded items for review, and making fallback heuristics visibly distinct from verified intent are super practical ways to keep release notes honest when context is partial or APIs degrade.

Collapse
 
aheadkit profile image
AheadKit •

The v1.4.0 story is the one that stays with me. A memory leak that crashed pods under peak traffic, retold as "optimized JSON payload serialization for low-latency clients". That is not a summary error, that is a press release for a fire. I keep thinking about the gap between what happened and what got written down, because I measured a version of it last week: a finished step missed its save by 5.9 seconds, so the log said the work was banked and the patch said otherwise. Your counterfactual test is the part I want to steal. Do you have an FPR number from it yet, or is that still the next run?

Collapse
 
kursatyz profile image
Kürşat Yılmaz •

Raw diffs only record line-level mutations, so prompting an LLM without linked issue graphs trades the CI latency and context-window overhead of graph hydration for plausible-sounding causal hallucinations in production release notes, while counterfactual evals fail silently whenever engineers merge unlinked hotfixes under incident pressure. Diffs record mutations, not intent.