Skip to content

fix(rework): anchor rework-pr prompt to current branch tip + configurable token cap (§56)#440

Merged
SaJaToGu merged 1 commit into
developfrom
codex/rework-pr-fix
Jun 25, 2026
Merged

fix(rework): anchor rework-pr prompt to current branch tip + configurable token cap (§56)#440
SaJaToGu merged 1 commit into
developfrom
codex/rework-pr-fix

Conversation

@SaJaToGu

Copy link
Copy Markdown
Owner

Closes §56 (docs/BACKLOG/open.md).

Three failure modes addressed

Measured across 7 solver runs in this session (data in §56):

  • 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 → no_patches): read OPENROUTER_REWORK_MAX_TOKENS (default 16384) instead of hardcoded 8192.
  • Mode C (model writes full rewrite-from-scratch diff that git apply rejects 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

  • Branch: codex/rework-pr-fix
  • Tests: ./.venv/bin/python -m unittest tests.test_validation.test_github_client tests.test_validation.test_rework -v (39 OK)
  • Tests: ./.venv/bin/python -m unittest tests.test_openrouter_worker -v (52 OK)
  • Tests: ./.venv/bin/python -m unittest tests.test_solve_issues -v (163 OK)
  • git diff --check: clean
  • Full python -m unittest discover -s tests: skipped — known slow repo-profiling path; the relevant single test was green in isolation (same caveat as in reports/handoffs/to-codex-20260625-1821-rework-pr-fix.md).
  • Live 3-run rework validation: not executed. No open PRs were available to repro against right now. Tracked as a follow-up to verify against the next real rework case.

Stash

stash@{0} from the earlier fix/opencode-dynamic-models work (the original §56 draft body) is untouched and still available if needed.

Out of scope (NOT touched)

Diff: 6 files, +254/-5.

…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 SaJaToGu merged commit 166f8b2 into develop Jun 25, 2026
2 checks passed
@SaJaToGu SaJaToGu deleted the codex/rework-pr-fix branch June 25, 2026 17:19
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant