Repository navigation
fix(host): a stop that stopped nothing now fails; empty prompts are refused - #1574
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
abortcalls 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— anabortnaming a queued run now fails with an explanation and sends nothing; the waiting message is left alone (cancel_queued_runstays the queue panel's command). Anabortnaming 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_innerrejects 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 tocancelled.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→ cleancargo clippy -p future-host --all-targets -- -D warnings→ cleancargo test -p future-host --lib→ 2223 passed, 0 failed, 14 ignoredvitest run src/features/agent/useAgentThreadState.abort.test.tsx→ 10 passedtsc --noEmit(desktop) → cleanUser-visible changes
<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.0b3499dfd.46ea989ca.Notes
No migrations, no default-value or performance changes, no new configuration. The queue panel keeps its own
cancel_queued_runpath unchanged.