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 (58)

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
 
gautamtalksdev profile image
Gautam K •

Falling back to heuristics while keeping ungrounded items clearly separated is the right call. Better a smaller honest summary than an invented reason.

Collapse
 
yahhi profile image
Valentina Koniukhova •

I stopped reading commit messages a while ago. My agents write them, and mostly my agents read them later. The issue-link approach assumes the why lives in an issue. In a solo project with an agent it mostly lives in the chat session, and that's gone after the session ends. What worked for me: the agent writes the why into the commit body at commit time, while it still has the context. For example: "the privacy page promises credential-shaped values are masked in logs; a canary test came back unmasked; the code only masked named fields". A later agent can build an honest release note from that without guessing. And it is the default behaviour of claude code. In my opinion: not bad, enough if I will need to dive in details anytime later

Collapse
 
dafili profile image
Renhua Wei •

Measure the substrate before blaming the model: on my own repo git log --format=%b is empty for 23 of 120 commits and under ten words for 50, so for 42% of the history there is no why to retrieve and any summary of those is extrapolation with a citation. Index PR bodies and issue links as a separate corpus, and make the generator name the artifact per claim instead of per commit.

Collapse
 
johnnylemonny profile image
𝗝𝗼𝗡𝗻 Necoz •

Measuring the substrate before tuning the model is a great point. When commit bodies are sparse or missing, forcing a rationale is just extrapolation with extra steps. Indexing PR bodies and issue links separately and tying citations to the specific supporting artifact per claim rather than the commit as a whole makes provenance much cleaner.

Collapse
 
dafili profile image
Renhua Wei •

Splitting the corpora is right, but measure corpus two before you trust it: gh api repos/:owner/:repo/pulls --paginate -f state=closed --jq '.[] | [.merge_commit_sha, (.body|length)] | @tsv' joined against git log --format=%H shows which merges carry a real body and which are just the title repeated. I'd set the bar at 100 characters and label everything under it unknown rather than citing the commit β€” a citation pointing at a body that says "fix tests" is the same extrapolation with a nicer reference.

Thread Thread
 
johnnylemonny profile image
𝗝𝗼𝗡𝗻 Necoz •

Checking PR body lengths against merged commits before trusting the second corpus is a sharp way to catch title-only or near-empty descriptions. Setting a minimum threshold like 100 characters and marking shorter ones as unknown keeps a citation from dressing up a "fix tests" note as real rationale.

Thread Thread
 
dafili profile image
Renhua Wei •

Run the join before you trust it: squash and rebase merges come back with merge_commit_sha null, so a hash join quietly drops exactly the PRs whose body is the only rationale you have. Count the loss first β€” gh api repos/:owner/:repo/pulls?state=closed --paginate --jq '.[] | select(.merged_at) | .merge_commit_sha' | grep -c null β€” and if that number is above zero, attach bodies through the "(#123)" suffix in the squash subject instead of the sha.

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
 
friga profile image
Artur PokΕ‚adek •

The missing why bites inside a single repo too. I had a cache fix quietly undone by a later change, because nothing next to that value said why it was there. Now a bug that comes back gets a test or a note saying what must not change.

Collapse
 
johnnylemonny profile image
𝗝𝗼𝗡𝗻 Necoz •

That cache regression hits on why the missing "why" hurts future maintainers and agents just as much as release notesβ€”a bare value looks arbitrary until someone reverts it and reopens an old bug. Turning recurring bugs into regression tests or explicit inline invariants is one of the best ways to keep that context alive right next to the code. Thanks for sharing that lesson.

Collapse
 
friga profile image
Artur PokΕ‚adek •

Thanks. Keeping it inline is the key part for me, a note in a separate doc is the first thing nobody reads.

Collapse
 
ascendra_ventures_92c21f2 profile image
Ascendra Ventures •

The memory-leak patch that became "optimized JSON payload serialization" is the clearest example I have seen of why a diff is the wrong source for intent. The model was not careless. It was given the what and asked for the why, so it filled the gap with the most plausible story.

We ran into the same shape of failure at Ascendra Ventures while building memory for AI coding tools. An audit of about three months of chats, roughly 7,000 prompts, showed the same context being retyped because the reasons behind decisions vanished when a window closed. Adding memory fixed the repetition, but not the trust: one parser read a single column off and reported numbers that were confidently and uniformly wrong. The lesson we wrote down was to put the model in the middle and never on the edges, with plain code deciding what counts as grounded. Requiring linked issues does exactly that for release notes.

When a commit has no linked issue at all, do you let the model say nothing rather than guess?

Collapse
 
johnnylemonny profile image
𝗝𝗼𝗡𝗻 Necoz •

Putting the model in the middle rather than on the edges, with deterministic code governing what counts as grounded, is such a clean rule of thumb, especially when an off-by-one parser bug can propagate uniformly wrong numbers across stored memory. When there is no linked issue at all, the pipeline avoids guessing intent and falls back to light, ungrounded summaries or deterministic heuristics kept apart from issue-backed claims rather than inventing a rationale. Thanks for sharing those findings from your audit.

Collapse
 
johnnylemonny profile image
𝗝𝗼𝗡𝗻 Necoz •

Putting the model in the middle while deterministic code owns the boundaries and grounding rules is a great way to frame it. A single off-by-one parser error shows how easily bad upstream inputs become confidently wrong output. When a commit has no linked issue, we don't let the model invent intent; it falls back to lightweight, non-speculative summaries or leaves the rationale unstated rather than guessing. Thanks for sharing those findings from your audit.

Collapse
 
kreout profile image
Andrei Ovcharenko •

There's a cross-repository edge case in resolveLinkedIssueNumbers: the regex captures repoPrefix, but the mapping discards it, so Fixes other/project#42 becomes just 42. If the caller fetches that number from the current repository, the release note can get a convincing rationale from an unrelated issue. I'd preserve the repository with each issue number, or explicitly skip references outside the current repo.

Collapse
 
johnnylemonny profile image
𝗝𝗼𝗡𝗻 Necoz •

Good catch on that cross-repo edge case. Dropping repoPrefix in resolveLinkedIssueNumbers means Fixes other/project#42 can collapse into #42 in the current repo and pull context from a completely unrelated issue. Preserving the target repository alongside each issue number or filtering out external repo references unless explicitly supported is a great safeguard against accidental context mismatches. Thanks for pointing that out.

Collapse
 
kling4ai-production profile image
Kling4 AI •

Turning a memory-leak buffer removal into 'optimized JSON payload serialization' is painfully accurate. A raw diff shows timeoutMs going from 5000 to 15000, never that a downstream gateway started dropping handshakes. Pulling linked PR descriptions or incident tickets into the prompt helps way more than feeding bare diffs.

Collapse
 
johnnylemonny profile image
𝗝𝗼𝗡𝗻 Necoz •

Incident tickets and linked PR discussions carry the exact operational context that a raw diff strips away. Giving the model those upstream artifacts turns release notes from guesswork into a reliable record of why the change was actually needed.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.