fix(rework): anchor rework-pr prompt to current branch tip + configurable token cap (§56)#440
Merged
Merged
Conversation
…able token cap (§56)
Three failure modes measured across 7 solver runs in this session
(see BACKLOG §56 in docs/BACKLOG/open.md for the full data):
- Mode A (OpenRouter 400 before any token output): stop forcing
use_structured_output=True in the rework code path; emit a plain
patch prompt via worker.build_patch_prompt(structured=False).
- Mode B (output truncated by 4096-token cap, then 'no patches'):
read OPENROUTER_REWORK_MAX_TOKENS (default 16384) instead of the
hardcoded 8192.
- Mode C (worker writes a full rewrite-from-scratch diff that
git apply rejects against the current branch tip): rework prompt
now carries the current head SHA + the existing PR commit list
and instructs the model to produce an incremental patch only.
Plus: ValidationGitHubClient.get_pull_request_commits() for the new
prompt context (404 returns []). Tests added for prompt shape,
commit formatter, max_tokens override, and worker invocation
without response_format.
Branch: codex/rework-pr-fix (uncommitted before this commit)
Tests: 39+52+163 OK; git diff --check clean
Full discover: skipped (known slow repo-profiling path, single
relevant test green in isolation)
Live 3-run rework: not executed (no open PRs available right now)
stash@{0}: untouched
SaJaToGu
pushed a commit
that referenced
this pull request
Jun 25, 2026
- open.md: §56 stubbed out as DONE-via-PR-#440 (squash 166f8b2). Cross-references §57 (done) and the still-open patch-mismatch hardening for the normal solve path. - done.md: full §56 closure entry with three failure modes (A: 400, B: 4096 cap, C: rewrite-from-scratch diff), fix locations (prompts/rework_pr.md, scripts/validation/rework.py, scripts/validation/github_client.py), verification matrix (39+52+163 OK + GitHub CI green + user live review 'Sieht gut aus'), live-validation gap (no open PRs at fix time), and out-of-scope notes for §57 (now also closed), §58 (open), and the still-relevant patch-mismatch hardening for the normal solve path (potential §59). Backlog is now: §58 priority/3 open, plus the implied §59 (Patch-Mismatch-Hardening for the normal Solve-Pfad) which can be filed explicitly if/when we want a separate item.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes §56 (docs/BACKLOG/open.md).
Three failure modes addressed
Measured across 7 solver runs in this session (data in §56):
use_structured_output=Truein the rework code path; emit a plain patch prompt viaworker.build_patch_prompt(structured=False).no_patches): readOPENROUTER_REWORK_MAX_TOKENS(default 16384) instead of hardcoded 8192.git applyrejects against the current branch tip →patches_failed): rework prompt now carries the current head SHA + the existing PR commit list and instructs the model to produce an incremental patch only.Plus:
ValidationGitHubClient.get_pull_request_commits()for the new prompt context (404 returns[]).Verification
codex/rework-pr-fix./.venv/bin/python -m unittest tests.test_validation.test_github_client tests.test_validation.test_rework -v(39 OK)./.venv/bin/python -m unittest tests.test_openrouter_worker -v(52 OK)./.venv/bin/python -m unittest tests.test_solve_issues -v(163 OK)git diff --check: cleanpython -m unittest discover -s tests: skipped — known slow repo-profiling path; the relevant single test was green in isolation (same caveat as inreports/handoffs/to-codex-20260625-1821-rework-pr-fix.md).Stash
stash@{0}from the earlierfix/opencode-dynamic-modelswork (the original §56 draft body) is untouched and still available if needed.Out of scope (NOT touched)
scripts/review_pr.py(§54, done, unrelated)scripts/model_catalog.py(PR [feat] model_catalog: discover OpenCode free models live with cache + fallback (§55) #439, done)scripts/watchdog.py(PR [fix] watchdog: raise cost-cap defaults + staggered budget-ratio warnings #437 cost-cap, independent of this fix)Diff: 6 files, +254/-5.