Skip to content

cli: hold input for harnesses that can't take it mid-turn - #167

Merged
morajabi merged 3 commits into
mainfrom
claude/bridge-held-input-204ab2
Nov 23, 2026
Merged

morajabi merged 3 commits into
mainfrom
claude/bridge-held-input-204ab2

Conversation

@morajabi

@morajabi morajabi commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Rebuilds the "hold input for harnesses without steering" part of the closed #153, written fresh on current main.

Bug on main

ACP drivers advertise SteerNow/SteerNext/Queue as unavailable (crates/agent-driver-acp/src/harness.rs, acp_availability; every ACP driver reports SteeringSupport::Unsupported). But work.rs deliver() turned every message typed during a turn into Delivery::Steer. The ACP harness then returned SendError::Unavailable, so the input was marked Failed with "could not take this". /queue on ACP failed the same way. Codex, Claude and OpenCode declare steering, so they never hit this.

Change (cli/src/bridge/v2/work.rs only)

  • When a turn is running and the session can't take the delivery (no SteerNext, or no Queue for /queue), the input goes into a FIFO held list. The ledger marks it Pending. The sender gets one reply ("Queued: … runs after the current turn"), and queued_count in the run state includes it.
  • A new message also waits behind anything already held, so order holds even when nothing is running.
  • When a turn ends with any outcome (completed, failed, interrupted, connection lost), the oldest held input is sent through the hold machine as its own Turn, after that turn's answer posts. The rest wait for that turn to end.
  • Pause keeps held input. Resume runs it in order, using the existing Pending path.
  • A release or a lost session moves held input to retained, so it's offered ("Run it?") at the next acquisition, like native queued input a release keeps. A CLI restart reports it through the existing "restarted before this ran" path.
  • If a turn starts between the check and the send (Busy), the input is held at the front and keeps the context it already took.
  • /queue on a harness with no native queue starts a turn when nothing is running, instead of failing.

While an approval, plan or question card waits (second commit)

On main, a message typed without replying to the card went into the blocked turn as a steer. Claude and Codex can't act on it until the card is answered, and the sender wasn't told. It is now held the same way, with the note "Held: … is waiting on your answer to the request above. This goes to it once you answer." When the card closes (answered, cancelled, or the turn ends), held input goes out: as a steer on Claude/Codex/OpenCode, or as the next turn on ACP.

Chosen: hold, not deny-with-feedback. Turning any typed message into the denial's feedback would deny a tool the person might have meant to approve ("yes go ahead"). Holding makes no decision for them and composes with the existing buttons: tap "No, and tell Claude what to do differently" and the held message then reaches Claude as that "what to do differently". The button itself still sends Claude's fixed denial text. Card rendering, Codex elicitation and the card-rejection path are untouched.

A card blocks input only while the live session still reports its interaction pending, and any open card counts. A card left by a crashed or released session never holds input, and answering the newer of two parallel cards keeps waiting for the older one. Input is released when the turn ends or any interaction closes.

Apart from both cases above, harnesses that support steering are unchanged. One side effect: /queue during a turn on a Codex without the gated thread/queue/add used to fail and now waits the same way.

Protocol / schema

No proto, wire or DB schema changes. AgentSessionState.queued_count is an existing field. It now also counts input the bridge is holding.

Tests (faults.rs, through the real runtime, work actor and SQLite ledger)

The scripted session gets an ACP-shaped mode: turns stay live until the test ends them, with no steering and no native queue.

  • without_steering_a_message_waits_for_the_turn_whatever_its_end: held, not failed; delivered as a turn after Completed, Failed, Interrupted and ConnectionLost

  • held_messages_run_one_turn_each_in_order: 3 held messages go out one per turn, in order, each exactly once

  • pause_keeps_held_input_until_resume

  • queue_without_a_native_queue_runs_after_the_turn

  • an_edited_held_message_runs_once: edits while held and after it ran don't deliver it again

  • a_steering_harness_still_steers_the_running_turn

  • a_message_typed_while_a_card_waits_goes_in_once_it_is_answered: held while an approval card waits, untouched by other events, then steers the turn once the card closes with a "No"

  • held_input_waits_for_every_open_card: answering the newer of two cards keeps input held for the older one

  • a_card_from_an_ended_session_holds_no_input: after a crash with a card up, the next message runs in the fresh session; held input is offered once even when the hold machine reports it too

The card test fails when the card check is disabled. The last two fail with the earlier waiting-based check.

Against main's work.rs, the first 5 fail and the steering test passes.

cargo test -p inline-cli --bin inline bridge::: 670 passed, 0 failed. cargo clippy -p inline-cli --bin inline --tests -- -D warnings: clean.

Review notes

  • Each held message runs as its own turn rather than being merged into one. That keeps per-input ledger tracking simple. Merging them would be a follow-up if three back-to-back turns feel noisy.
  • After a stop (not a pause), held input runs. The assumption is that what someone typed during the turn is usually the redirect they stopped it for.

🤖 Generated with Claude Code

acp agents advertise no steering and no native queue, yet v2 sent every
message typed during a turn as a steer, so it failed with "could not take
this". such input is now held in order, the sender is told it's queued,
the run state counts it as queued, and each held message starts its own
turn when the one before ends, whether it completed, failed or was
stopped. pause keeps it until resume; a release or a lost session keeps it
pending and offers it next time. /queue without a native queue does the
same. steering harnesses are unchanged.
while an approval, plan or question card waited, a message typed without
replying to it went into the blocked turn, where the harness could not act
on it, and the sender was not told. it is now held with a note pointing at
the card, and goes in once the card is answered: after a "no", it reaches
the agent as what to do differently.
a card left by a session that crashed or was released held every later
message, since nothing cleared it and no turn started. input now waits only
for an open card whose interaction the current session still reports
pending, so answering the newer of two cards keeps waiting for the older
one. held input a release keeps is offered once, with one note, and a held
message that loses a race to a turn isn't told twice.
@morajabi
morajabi force-pushed the claude/bridge-held-input-204ab2 branch from 886cfed to a4fc164 Compare November 23, 2026 14:39
@morajabi
morajabi marked this pull request as ready for review November 23, 2026 15:13
@morajabi
morajabi merged commit c4bee45 into main Nov 23, 2026
52 checks passed
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