Skip to content

fix: spend a follow-up only when its prompt is submitted - #87

Merged
youdie006 merged 1 commit into
mainfrom
fix/followup-budget-on-send
Nov 4, 2026
Merged

youdie006 merged 1 commit into
mainfrom
fix/followup-budget-on-send

Conversation

@youdie006

Copy link
Copy Markdown
Owner

Problem

An MCP follow-up (pro_consult with continue_task or continue_thread) reserved one of the automatic follow-ups (PRODEX_MAX_AUTO_FOLLOWUPS, default 5) before the consult task was created. A send the browser refused before anything was typed still used it up.

Measured 2026-11-02 in the browser container's ledger: two follow-ups in one conversation, refused as composer_not_ready, were recorded as its follow-ups 3 and 4 of 5, with no prompt sent.

Change

  • assertFollowupAvailable checks the budget under the same lock without writing anything. It still runs before any task is created or the browser is touched, so an exhausted budget returns awaiting_user exactly as before.
  • sendChatGptPrompt takes beforePromptSubmit, run once the prompt is typed and checked, right before Enter. The MCP consult reserves the follow-up there. A retry after browser recovery reserves once.
  • If another follow-up used the last of the budget while this one waited for the browser, the send stops before submitting. The task is recorded as blocked with followup_approval_required, and the caller gets awaiting_user. The typed prompt stays in the composer until the next send clears it.
  • The ledger format and its validation are unchanged, so older installs reading the same .bridge still agree on the count.
  • docs/clients.md and CHANGELOG describe what counts.

Verification

  • New tests:
    • The hook runs after the prompt is typed and before any Enter.
    • A refusing hook means no Enter is sent.
    • A follow-up refused before submitting leaves the budget for the retry.
    • The race ends at awaiting_user with the task recorded as blocked.
  • The existing "failed attempt counts" test now fails after submitting, which still counts.
  • npx tsc --noEmit is clean.
  • The full suite passed after a build: 1865 passed, 3 skipped.
  • Not run: a live send. The hook sits on the existing submit path, which the fake-CDP tests drive.

The container branch port follows separately.

An MCP follow-up reserved one of the automatic follow-ups before the task
was created, so a send the browser refused before typing still used it up.
Measured 2026-11-02 in the browser container: two follow-ups in one
conversation refused as composer_not_ready were recorded as its follow-ups
3 and 4 of 5, with no prompt sent.

The consult now checks the budget without spending it before any task or
browser work, and reserves the follow-up from a new beforePromptSubmit step
that the send runs once the prompt is typed and checked, right before
Enter. A retry after browser recovery reserves once. If another follow-up
used the last of the budget while this one waited for the browser, the send
stops before submitting, the task is recorded as blocked with
followup_approval_required and the caller gets awaiting_user. The ledger
format is unchanged.

Verified: new tests for the hook order (typed, no Enter yet), a refusing
hook (no Enter), a pre-submit refusal that leaves the budget, and the race;
tsc clean; full suite 1865 passed, 3 skipped.

Claude-Session: https://claude.ai/code/session_01EMqNwnnhHXznd2P2PDsaDV
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

What this touches

  • browser adapter
  • CLI
  • tests

7 file(s), 240 line(s) changed. Tests changed.

This is an automated first pass, not a review. CI is the gate; a person decides.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T23:51:45.420305Z bda939c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@youdie006
youdie006 merged commit d8333f2 into main Nov 4, 2026
7 checks passed
youdie006 added a commit that referenced this pull request Nov 4, 2026
…ntainer image

An MCP follow-up reserved one of the automatic follow-ups before the task
was created, so a send the browser refused before typing still used it up.
This container's ledger recorded two follow-ups refused as
composer_not_ready on 2026-11-02 as follow-ups 3 and 4 of 5.

Same change as main PR #87: the budget is checked without spending it
before any task or browser work, and reserved from beforePromptSubmit,
which the send runs right before Enter.

Verified: tsc clean; full suite 2179 passed, 3 skipped; release:verify ok.

Claude-Session: https://claude.ai/code/session_01EMqNwnnhHXznd2P2PDsaDV
youdie006 added a commit that referenced this pull request Nov 4, 2026
0.40.50 (#84-#87) published and installed on WSL, M3 and the Mac mini;
M4 was unreachable. Both browser containers now run c7c9f35. Includes the
live check of #87 on the WSL container: a follow-up refused before
submitting left the budget, and the ledger holds one reservation.

Claude-Session: https://claude.ai/code/session_01EMqNwnnhHXznd2P2PDsaDV
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