Skip to content

fix(host): a stop that stopped nothing now fails; empty prompts are refused - #1574

Merged
huichen merged 6 commits into
mainfrom
pr/huichen
Nov 9, 2026
Merged

huichen merged 6 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

A stop request that stopped nothing used to report success, and a send with no text and no attachment used to be admitted as an invisible turn. Both are host-side boundary decisions, so both are fixed here, with the regressions pinned by tests on the host and on the desktop client.

Why

Measured on 2026-11-09 in one real conversation: four abort calls for a run that was streaming all answered "is no longer active", and each one "succeeded" by cancelling the queued message instead — the reply the reader wanted to stop kept streaming, and the stop report was a lie. In the same period three sends with neither text nor an attachment were admitted on a busy conversation; because a queued send deliberately draws no bubble, the reader got a turn they could not see, retry or take back, and the only trace was the host failing to persist the user entry.

Commits

  • fix(host): a stop that stopped nothing is a failure, not a queued cancel — an abort naming a queued run now fails with an explanation and sends nothing; the waiting message is left alone (cancel_queued_run stays the queue panel's command). An abort naming an already-ended run while another run streams now fails and names the live run instead of answering success.
  • fix(host): refuse a prompt with neither text nor an attachment — agent_prompt_inner rejects an empty message before it reaches the Agent, so every caller (composer, queue-panel edit, dictation, staged prompt, phone client) gets the same refusal instead of re-implementing the check.
  • test(desktop): pin that stop names the run that is streaming — the desktop abort path must send the streaming run's id.
  • test(host): pin that a refused stop leaves the queued message queued — a refused stop must not rewrite the row to cancelled.

Verification

Run locally on the branch tip (9c56e03e4) with the pinned toolchain (rustc 1.99.1, ulimit -n 8192):

  • cargo fmt -p future-host -- --check → clean
  • cargo clippy -p future-host --all-targets -- -D warnings → clean
  • cargo test -p future-host --lib → 2223 passed, 0 failed, 14 ignored
  • vitest run src/features/agent/useAgentThreadState.abort.test.tsx → 10 passed
  • tsc --noEmit (desktop) → clean

User-visible changes

  • Stopping a run that is still queued — before: pressing stop silently took the waiting message back and reported success. After: it fails with "run <id> has not started yet, so there was nothing to abort; take the waiting message back through the send queue instead", and the message stays queued. Revert: 0b3499dfd.
  • Stopping an already-ended run while another run streams — before: success, with the other run left streaming. After: an error naming the run that is actually executing. Revert: 0b3499dfd.
  • Sending with no text and no attachment — before: admitted as an invisible turn. After: rejected with "A message needs text or an attachment.". Revert: 46ea989ca.

Notes

No migrations, no default-value or performance changes, no new configuration. The queue panel keeps its own cancel_queued_run path unchanged.

An `abort` answered with `run X is no longer active` was reconciled by
cancelling the message waiting in the Agent's session queue and reporting
AbortRequested, and an abort naming a run that simply was not the active one
was reported as AbortRequested without touching anything. Both turned a stop
that stopped nothing into a success report.

Measured 2026-11-09 on a conversation whose reply had been streaming for half an
hour: the view pressed stop four times, every `abort` was refused, every press
"won" by cancelling a queued message (`cancelled / abort_requested "Terminated
by user."` on 827856b7 and 655fa78b), and the run the reader wanted stopped
(f34acb8d) kept streaming to the end.

- a queued run is now refused with the reason, and the queue is not touched:
  taking a waiting message back is `cancel_queued_run`, a different command the
  queue panel asks for;
- a stale row stays a no-op while nothing is executing (the reader's goal, "not
  running", already holds), but once ANOTHER run is executing it is a failure
  that names that run. The live run is still never aborted from here, because
  it may belong to another client - the caller is told instead.

Both endings are pinned by tests that go red when the branches are reverted.
An empty prompt is not a turn, and nothing below the Host boundary checked:
the Agent admitted it (a run row, a queued receipt whose user entry is an empty
text block), and a queued send deliberately draws no bubble in the
transcript - so the reader got a turn they could not see, retry or take back.
Measured in the same session as the stop bug: three such sends were admitted as
queued runs, and the only trace was the Host failing to persist their user
entry ("accepted by the Agent but its user entry was not found").

The composer guards this for itself, but every other caller would have to
re-implement that guard (the queue panel's edit, the dictation layer, a staged
prompt, a phone client), so it belongs at the boundary every client crosses.

The receipt's user entry is built from the prompt at admission
(agent/src/rpc/session_prompt.rs), which is why the empty text proves the
message itself was empty rather than an Agent-side artifact.
The view picks its stop target from the conversation's newest local run row
(`activeRunIdOf(recentRun)`), and a prompt written while a reply streamed is
newer than the run that is executing. A run the Agent accepted but holds queued
is not that run, so it is excluded from the anchor - otherwise stop names the
waiting message, the Agent refuses it, and the reply keeps streaming.

The case is pinned end to end: a reply streams for R9, a message queued behind
it becomes the newest row (Q1), and stop must still name R9 - and never Q1,
whose removal is the queue panel's own action. Reverting the queued exclusion
makes the test stop Q1, which is what the incident recorded.
The entry point a stop actually uses, against a real row: `abort_run` naming a
message the Agent holds queued must fail, and the row must still read `queued`
afterwards. Reverting the branch to the queued-cancel fallback rewrites it to
`cancelled / abort_requested "Terminated by user."` - the exact fingerprint the
2026-11-09 incident left on two waiting messages while the reply the reader was
trying to stop kept streaming - so this test turns red on the revert.
@huichen
huichen enabled auto-merge (squash) November 9, 2026 14:29
@huichen
huichen merged commit dd15521 into main Nov 9, 2026
21 checks passed
@huichen
huichen deleted the pr/huichen branch November 9, 2026 14:45
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