Skip to content

perf(review): keep the review prompt an index of linked items - #1762

Merged
obviyus merged 2 commits into
mainfrom
lean-review-context
Oct 8, 2026
Merged

obviyus merged 2 commits into
mainfrom
lean-review-context

Conversation

@obviyus

@obviyus obviyus commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What

The review prompt becomes an index instead of an archive. The reviewer already has a read-only GH_TOKEN and GitHub network access, so it fetches a linked item's full record when that item matters.

  • Primary PR body once. For a PR, issue.body and pullRequest.body are the same text. The prompt keeps it under issue and puts "[same as issue.body]" in pullRequest. If the two reads differ, both stay.
  • Checks as counts. pullChecks gives counts by outcome and lists only runs/statuses that did not pass. Before, it listed up to 100 runs, most of them green.
  • Linked items without bodies. relatedItems, closingPullRequests and referencingMergedPullRequests keep identity, state, title, labels and why they are linked. Their bodies are omitted only when the reviewer can read GitHub (allowlisted-proxy or unrestricted). With no network they stay inline as before.
  • The prompt tells the reviewer this and names the gh issue view / gh pr view reads.

Only the prompt view changes (src/clawsweeper-prompt-context.ts). Collected context, source-revision digests, check digests, close guards and reports are untouched. Policy v32.

Why

A dumped prompt for openclaw/openclaw#167298 was 190k chars. 49k chars were related-item bodies (each linked PR body sent twice), 11k chars were check runs, and the PR body appeared twice.

Proof

Shipped entry point, same PR, run with a hosted-like Codex home (.github/actions/setup-codex/review-permissions.toml, --codex-sandbox clawsweeper-review, read-only GH_TOKEN):

pnpm run review -- --local-only --target-repo openclaw/openclaw --item-number 167298 --codex-model gpt-6.1-sol --codex-sandbox clawsweeper-review --output-retention debug --artifact-dir <dir>

main branch
prompt chars 190,279 129,305
context chars ~101,000 37,025
decision keep_open, patch correct keep_open, patch correct
findings none none
ratings (proof/patch/overall) B/B/B B/B/B
real behavior proof sufficient sufficient

Correction (after merge): on the branch the reviewer tried to read the two linked items it cared about (gh issue view 87637 --json body,comments; gh pr view 92165 --json body,comments), but both reads failed with HTTP 403: the review network allows only read methods, and these commands use GraphQL POST. The verdict above came without those bodies. The follow-up PR points reviewers at REST gh api reads, which succeed under the same profile.

Tests: linked-item bodies are omitted with network and kept without it; checks are counted and only non-passing ones listed; the primary body appears once with its coverage under issue. pnpm run check passes.

Codex /review P2 (deduping long bodies by their 12,000-unit prefix could drop a PR body edited late between the two reads) fixed in b53848280: the PR body is deduped only when primaryBodySourceSha256 matches. Regression test: same prefix, different late proof trace keeps both bodies and the PR source hash; it fails on the prefix comparison and passes now.

Limits: one PR compared; review verdicts are model output and can vary between runs.

Merge Danger

Door: two-way: prompt shape only; revert restores the old view.

Blast radius: every hosted review prompt. If the reviewer skips a linked item it needed, that item's detail is missing from the decision; the prompt names the read to use.

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 12:41 PM ET / 16:41 UTC.

ClawSweeper review

What this changes

This PR deduplicates the primary PR body, summarizes passing checks, and replaces linked-item bodies with an index when GitHub access is available.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, bounded optimization with shipped-CLI evidence and focused coverage, without an actionable correctness concern.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body records the shipped review CLI exercising the changed prompt projection with the review sandbox and read-only GitHub access: input shrank by 60,974 characters and the reviewer retrieved relevant linked items. The full-source identity correction has focused regression coverage. No stored-data contract changes, so migration is unnecessary; the observed model verdict is limited to one comparison.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes
User problem: Reviewers receive large duplicated records that consume model input without adding evidence.
Reason: The measured reduction is substantial, and prior merged history establishes the author’s connection to this review area. The change preserves offline evidence and existing safety owners.

Merge readiness

✅ Ready for maintainer review

This PR provides a useful, measured reduction in review input that current main does not provide. No actionable patch defect was found.

Priority: P3
Reviewed head: b538482802f2944ff1140e18bb2ba3616feb61bf

Before merge

None.

Findings

None.

Agent review details

How this fits together

ClawSweeper gathers GitHub discussion and source evidence for a model to review an issue or PR. This change reduces the prompt representation while preserving the collected records used for freshness and safety checks.

flowchart TD
 A[Collected GitHub records] --> B[Prompt projection]
 B --> C[Primary body and check summary]
 B --> D{GitHub access available}
 D -->|Yes| E[Linked item index]
 D -->|No| F[Inline linked bodies]
 C --> G[Reviewer]
 E --> G
 F --> G
 G --> H[Read relevant linked records]
Loading

Technical review

Best possible solution:

Keep the prompt projection at the existing review-runtime boundary while preserving full collected records and fetching decision-relevant linked evidence on demand.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a bug report; the supplied CLI comparison demonstrates the oversized input and its reduction.

Is this the best way to solve the issue?

Yes. A prompt-only projection is a narrow solution that preserves freshness, source capture, offline context, and existing admission serialization.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against fb5a0d95b269.

Provenance checked

Testing

Proof path: shipped entry point. Added test files: 1.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit 197df62 adds src/clawsweeper-review-runtime.ts:496 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 197df625648b; files: src/clawsweeper-review-runtime.ts)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Review metrics

Metric Value Why it matters
Observed prompt reduction 60,974 fewer characters, approximately 32% The supplied shipped-CLI comparison demonstrates a material reduction in model input.
Production and test growth production +83/-4; tests +102/-9 The bounded projection and focused regression coverage justify the added code.

Labels

Label changes:

  • add P3: This is a measured review-input efficiency improvement without an urgent user-facing failure.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a measured review-input efficiency improvement without an urgent user-facing failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

@obviyus
obviyus merged commit 3db5c86 into main Oct 8, 2026
25 of 28 checks passed
@obviyus
obviyus deleted the lean-review-context branch October 8, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant