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 (35)
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.
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.
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.
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.
Great breakdown of the diff-context gap. We ran into almost the exact same failure mode when generating changelogs solely from commit logs β models love inventing "performance improvements" whenever a diff removes allocations or bumps a timeout.
Adding the linked issue summary and the "Motivation / Risk" section from the PR template into the prompt fixed most of the hallucinations, since that's usually the only place the actual why lives.
That performance improvements reflex around deleted allocations and bumped timeouts shows up everywhere when context is missing. Pulling in both the linked issue summary and an explicit Motivation / Risk section from PR templates is a very clean way to capture intent where it actually gets written down.
That opening example of an emergency memory leak patch turning into "optimized JSON payload serialization for low-latency clients" hits way too close to home. LLMs are fundamentally trained to be optimistic narrative-completers, so when you feed them raw diffs without context, they naturally treat every deleted line or tweaked constant as an intentional, user-facing improvement.
The point about AI-generated PR descriptions compounding this problem is huge, too. Weβre increasingly seeing a "game of telephone" where an AI coding agent writes an unsupported-plausible rationale in the PR body, and then a second AI summarizer treats that hallucinated PR description as ground truth for the release notes. Anchoring the pipeline back to the linked GitHub issueβwhere a human actually described the pain pointβcuts right through that noise.
Also really appreciate the Unix-style decoupling of
--output stdoutfrom side effects like opening PRs. Too many CI tools assume they should own the entire write lifecycle out of the box, which makes local dry-runs and custom release workflows way harder than they need to be.That "game of telephone" between an AI coding agent and a changelog summarizer is a great way to put it. Once a plausible but unsupported rationale enters the PR body, downstream tools easily treat it as established fact. Going back to the linked issue where the actual pain point was reported helps break that chain, and keeping
--output stdoutseparate from write side effects makes local testing and custom pipelines much cleaner. Thanks for sharing such a thorough response.The counterfactual evaluation approach is particularly important here. A release note can be technically consistent with a diff and still be completely wrong about the reason behind the change. One additional safeguard is to preserve the evidence chain for every generated claim: linked issue, relevant PR context, commit, and the specific user impact being described. Issue links are useful signals, but they can be stale, overly broad, or attached to PRs that address only part of the original problem. Iβd also keep unsupported rationale separate from verified facts rather than letting the model turn missing context into confident prose. That makes release notes easier to audit and gives teams a clear fallback when the source history cannot establish intent.
That evidence-chain framing, linking issue, PR context, commit, and concrete user impact - hits on why a diff-consistent note can still miss the mark when an issue is stale, broad, or only partially resolved. Keeping unsupported rationale separate from verified facts makes auditing straightforward and gives a clear fallback when history cannot establish intent. Thanks for adding such a sharp breakdown.
The decoy cases are useful because a tidy explanation can still be completely unsupported. I would add a linked issue that is real but belongs to a different repository, then check that matching issue numbers cannot supply the rationale. This evaluation design exercise has a useful follow-up about reward hacking; accepting any citation feels like exactly that kind of shortcut.
Testing against a real issue from a different repository and checking that colliding issue numbers cannot supply the rationale are sharp decoy cases. Accepting any citation blindly is a classic reward-hacking shortcut, so tightening the eval around cross-repo and number-collision traps is a great addition.