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.
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:
- Grounded intent: Accurately relays verifiable user and business motivations.
- Unsupported-plausible: A polished, convincing explanation that sounds authoritative but has zero backing in the actual issue or user bug report.
- 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);
}
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.
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 tostderr. -
--output file: Appends updates locally toCHANGELOG.mdwith 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
- Stop summarizing diffs: Diffs tell you what changed in syntax; linked issues explain why the change mattered to users.
- Benchmark against decoys: Use counterfactual test sets to quantify whether your LLM can reject plausible but ungrounded claims.
-
Keep delivery decoupled: Ensure your changelog generator can emit pure markdown to
stdoutwithout 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!
- π» GitHub: johnnylemonny

Top comments (58)
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! π
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.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.
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.
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?
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.
Falling back to heuristics while keeping ungrounded items clearly separated is the right call. Better a smaller honest summary than an invented reason.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
Thanks. Keeping it inline is the key part for me, a note in a separate doc is the first thing nobody reads.
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?
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.
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.
There's a cross-repository edge case in
resolveLinkedIssueNumbers: the regex capturesrepoPrefix, but the mapping discards it, soFixes other/project#42becomes just42. 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.Good catch on that cross-repo edge case. Dropping
repoPrefixinresolveLinkedIssueNumbersmeansFixes other/project#42can collapse into#42in 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.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.
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.