Skip to content

chore(pragent): upgrade the embedded runtime to pr-agent 0.45.0 - #225

Merged
huhamhire merged 2 commits into
devfrom
chore/pragent-0.45
Sep 8, 2026
Merged

huhamhire merged 2 commits into
devfrom
chore/pragent-0.45

Conversation

@huhamhire

Copy link
Copy Markdown
Owner

Upgrades the embedded review engine from 0.39.0 to 0.45.0, and bumps the development version to 0.12.0-dev.

How this was assessed

By diffing the 0.45.0 wheel against the vendored 0.39.0 tree, not by reading release notes: 82 of 123 files changed, including all eight we patch. Every claim below was then verified against the actually-installed runtime.

Two patches retired — upstream fixed the bugs

Patch 0.45.0
Single-line-hunk phantom line extract_hunk_headers now defaults an omitted hunk size to 1 instead of 0 — exactly what we were patching
Binary-safe diff get_diff_files now skips a file that fails to decode (with a warning) instead of crashing the review

Confirmed by probing the installed runtime (extract_hunk_headers("@@ -1 +1 @@") -> ("", 1, 1, 1, 1)), not assumed from a changelog. Two fewer things to keep in step with upstream.

Three new defaults would have corrupted our parsed output

This is the part of the upgrade that fails silently rather than loudly, and the reason it warranted a real diff. 0.45.0 turns on three features that append to the output this app parses as structured markdown:

Setting 0.45.0 default Effect here
pr_reviewer.persistent_finding_state true Appends a "resolved findings" section carrying upstream''s own cross-run state — which the app already owns via drafts / finding closures / re-review verdicts. Would both duplicate that concept and parse as extra findings.
pr_reviewer.enable_review_coverage_footer true Footer appended to the body, read by the parser as content
pr_code_suggestions.enable_suggestions_coverage_footer true Same

All three are now pinned off in buildPragentEnv, verified both ways: true by default, false under the override. The design doc records this as something to re-check on every upgrade — upstream adding a section is not a free improvement when you parse the output.

Everything else checked

  • All four remaining patches apply under 0.45.0 — none silently skipped by the version guard. Probed individually: get_line_link / get_repo_file_content / _prepare_repo injected, _get_completion wrapped, and the /describe assessment field injected (both prompt anchors still present).
  • get_line_link call sites are unchanged, so the structured /review line anchor — the primary source for jumping to a file:line — still works.
  • _get_completion still returns a 3-tuple on both return paths; the streaming path''s MockResponse now even carries finalized_usage, so token accounting may improve.
  • Telemetry (new telemetry/) ships disabled (otel.is_enabled = False, verified) with no built-in endpoint — nothing to handle for privacy or intranet use.
  • Default model moved to gpt-5.6, but CONFIG__MODEL is always set explicitly, so it does not reach us.

New capabilities worth knowing about (none adopted here)

  • algo/run_details.py — upstream now collects token usage natively via a ContextVar, which is what our _get_completion wrapper does. Could retire another patch, though we would still need a shim to get the data out of the process.
  • algo/review_merge.py + pr_reviewer.max_number_of_calls = 3 — chunked /review merged into one verdict. Real value for very large diffs, but it makes a single review cost up to 3 model calls; enabling it is a product decision.
  • git_providers/plain_diff_provider.py — a provider that does not need a git repo. Potentially removes the need to materialize a worktree; an architectural change worth evaluating separately.
  • algo/inline_comment_dedup.py — cross-run inline-comment dedup via fingerprint markers. Not applicable: we post comments ourselves rather than through pr-agent.

Verification

lint / typecheck / test / build pass; the runtime assembles and its build-time smoke test passes on 0.45.0.

Not exercised end to end. 0.45.0 revises six prompt .toml files, so the rendered markdown may have shifted in ways only a live run reveals — and the parser matches on section headings. Before merging, worth running /describe, /review and /ask once against a real PR and checking that findings still split into separate items, line anchors still jump, and no extra sections appear.

🤖 Generated with Claude Code

Assessed by diffing the 0.45.0 wheel against the vendored 0.39.0 rather than
reading release notes: 82 of 123 files changed, including all eight we patch.

Two patches are retired because upstream fixed the bugs. extract_hunk_headers
now defaults an omitted hunk size to 1 instead of 0, so a single-line change no
longer renders its old value as a still-present context line; get_diff_files now
skips a file that fails to decode instead of crashing the review on a binary.
Both were confirmed against the installed runtime, not assumed. The four
remaining patches were probed under 0.45.0 and all apply -- none silently
skipped by the version guard -- and get_line_link's call sites are unchanged, so
the structured /review anchor still works.

Three upstream features now default to on and append to the very output this app
parses, which would have surfaced as bogus findings rather than as an obvious
break: persistent_finding_state (upstream cross-run state the app already owns
through drafts, finding closures and re-review verdicts) and two coverage
footers. They are pinned off in buildPragentEnv, verified to be true by default
and false under the override.

Telemetry is new in 0.45.0 but ships disabled with no built-in endpoint, so it
needs no handling.

Also bumps the development version to 0.12.0-dev.

Not exercised end to end: 0.45.0 revises six prompt files, and whether the
rendered markdown still matches the parser needs a real /describe /review /ask
against a live PR.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@huhamhire huhamhire added dependencies Dependency updates enhancement New feature or request labels Sep 8, 2026
…eadings splitting it

Three defects surfaced by a real /describe run. None was introduced by the
0.45.0 upgrade -- the relevant upstream code is identical in 0.39.0 -- they had
simply never been noticed.

Line counts rendered as "+-1/--1". FilePatchInfo defaults num_plus_lines and
num_minus_lines to -1 and only the real platform providers fill them in;
LocalGitProvider does not. get_diff_files is wrapped rather than reimplemented
to backfill both from the patch text, counted by the same rule the platform
providers use, so upstream keeps owning how the diff is produced.

Every walkthrough link pointed at "#L-1". Upstream passes relevant_line_start=-1
to mean "the whole file", and -1 is truthy, so a plain falsiness check let it
through. The resulting fragment was then rejected by the anchor parser entirely
(its line group accepts only digits), so the link yielded no anchor at all --
the fix therefore also recovers a path-level anchor for these rows.

A merge tail in the PR description tore the result apart. `# Conflicts:` and the
`#<tab>path` lines beneath it are markdown H1s, and /describe frames its own
structure at H3, so the author's prose outranked the tool's structure and
produced sections named after conflicted files. Section splitting now takes a
minimum heading level, and describe splits only at H3 or deeper: quoted content
stays inside the section that quotes it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@huhamhire

Copy link
Copy Markdown
Owner Author

Follow-up: three defects found by a live /describe run

The end-to-end run this PR asked for turned up three problems in the output. None was introduced by the upgrade — the relevant upstream code is byte-identical in 0.39.0, they had simply never been noticed. Fixed in 91702d0.

1. Line counts rendered as +-1/--1. FilePatchInfo defaults num_plus_lines / num_minus_lines to -1 and only the real platform providers fill them in; LocalGitProvider never has. get_diff_files is now wrapped rather than reimplemented to backfill both from the patch text, counted by the same rule the platform providers use — upstream keeps owning how the diff is produced, which is the point of having dropped our own copy of it earlier in this PR.

2. Every walkthrough link pointed at #L-1. Upstream passes relevant_line_start=-1 to mean "the whole file" for each File Walkthrough row, and -1 is truthy, so our plain falsiness check let it through. Worth noting the second-order effect: the resulting fragment was then rejected by the anchor parser outright (its line group accepts only digits), so those links produced no anchor at all — the fix recovers a path-level anchor for these rows rather than merely tidying a URL.

3. A merge tail in the PR description tore the result apart. The description ended in:

Merge remote-tracking branch ''origin/feature/test'' into feature/test

# Conflicts:
#	package-lock.json
#	package.json

# Conflicts: and the lines under it are markdown H1s, while /describe frames its own structure at H3 — so the author''s prose outranked the tool''s structure and split the result into sections named after conflicted files. Section splitting now takes a minimum heading level, and describe splits only at H3 or deeper, so quoted content stays inside the section that quotes it. Other tools keep the old behaviour: their bodies are model output shaped by our prompts, not quoted user text.

Three regression tests cover the split, built from the actual output above.

Upgrade status

The live run also confirms the upgrade itself: the structure survived 0.45.0''s prompt changes, and the /describe Assessment section (our injected schema field) renders correctly in Chinese. Still worth a glance before merging: whether "jump to code" works on /review finding cards — that path degrades silently to plain text rather than erroring.

@huhamhire
huhamhire merged commit c79adc4 into dev Sep 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Dependency updates enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant