Skip to content

fix(chatgpt-review): plan-author early-exit once a complete protocol appears - #650

Merged
BorisTyshkevich merged 1 commit into
mainfrom
fix/chatgpt-review-plan-author-early-exit
Aug 8, 2026
Merged

fix(chatgpt-review): plan-author early-exit once a complete protocol appears#650
BorisTyshkevich merged 1 commit into
mainfrom
fix/chatgpt-review-plan-author-early-exit

Conversation

@BorisTyshkevich

Copy link
Copy Markdown
Collaborator

Root cause

waitForCompletion() required the entire ChatGPT turn to stop generating (no
visible "stop" button) AND hold stable for 7s before returning — for every CLI
mode alike. That's the right contract for pr/plan/issue mode, whose answer
ends with a VERDICT: line that could in principle still change if more text
follows. But plan-author mode's protocol is a fixed-content island:
parsePlanAuthorResponse already requires exactly one delimiter pair, so once a
valid PLAN_STATUS: READY/BLOCKED block appears, its content can never change
no matter what ChatGPT keeps writing afterward — this is explicitly tolerated
already (a documented, tested behavior: a trailing citation footnote after
PLAN_END doesn't invalidate the response).

What happened live

On /ship 630 phase 7, an Extra-High-effort plan-author turn kept the "stop"
button visible for 20+ minutes of further reasoning/tool calls after already
emitting a complete, valid plan
. waitForCompletion's !generating + stableMs requirement can never fire in that case, so the call timed out
despite a perfectly good answer already sitting in the DOM — the coordinator
had to recover it by hand by reading the live page directly.

Fix

For plan-author mode only: once the same complete-protocol match (checked via
the real parsePlanAuthorResponse parser, non-throwing) holds for two
consecutive polls — guarding against a transient mid-stream coincidence —
confirm it against the authoritative clipboard-copied Markdown (.innerText()
can strip the literal # heading syntax the parser's heading check requires)
and return immediately if it agrees, without waiting for generation to stop.
Falls back to the ordinary wait if the clipboard copy disagrees (never trusts
an unconfirmed match). Other modes are unaffected — the early-exit is gated on
mode === 'plan-author'.

Tests

Three new tests in tests/browser.test.mjs:

  • plan-author mode returns as soon as a complete protocol appears, without
    waiting for generation to stop.
  • non-plan-author modes still require generation to stop before returning
    (proves the change is properly scoped).
  • the early-exit requires the clipboard-copied Markdown to confirm the match
    before trusting it while still generating (proves no unconfirmed early
    return, and no infinite-loop risk).

48/48 skills/chatgpt-review tests pass (45 pre-existing + 3 new). Full
repository gate green — this change touches only skills/**, outside the
coverage-gated src/** tree.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01LwFPT465eDJqYcRa8HGNLz

…appears

waitForCompletion() required the WHOLE turn to stop generating (no visible
stop button) and hold stable for 7s before returning, for every mode alike.
That's the right contract for pr/plan/issue's trailing VERDICT line, but
plan-author's protocol is a fixed-content island: parsePlanAuthorResponse
already requires exactly one delimiter pair, so once a valid PLAN_STATUS:
READY/BLOCKED block appears, its content can never change no matter what
ChatGPT keeps writing afterward (more reasoning, another tool call, a
citation footnote — already tolerated by the same parser).

Observed live on #630 phase 7: an Extra-High-effort plan-author turn kept
the stop button visible for 20+ minutes of further tool calls after already
emitting a complete, valid plan. waitForCompletion's !generating+stableMs
requirement can never fire in that case, so the whole call times out
despite a perfectly good answer already sitting in the DOM — the coordinator
had to recover it by hand from the live page.

For plan-author mode only: once the same complete-protocol match holds for
two consecutive polls (guarding against a transient mid-stream coincidence),
confirm it against the authoritative clipboard-copied Markdown (innerText
can strip the literal '#' heading syntax the parser's heading check needs)
and return immediately if it agrees, without waiting for generation to stop.
Falls back to the ordinary wait if the clipboard copy disagrees.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LwFPT465eDJqYcRa8HGNLz
@BorisTyshkevich
BorisTyshkevich merged commit 3e7867b into main Aug 8, 2026
8 checks passed
@BorisTyshkevich
BorisTyshkevich deleted the fix/chatgpt-review-plan-author-early-exit branch August 8, 2026 11:06
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