You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2093ef5
Browse filesBrowse the repository at this point in the historyBrowse files
authored
feat(acp): stop one thread with cancel_thread_turn (#10002)
## Summary
Adds a new observer control type, `cancel_thread_turn`, that stops the
agent's turn in one thread of a channel. `buzz-acp` stops the session
that serves that thread through the same scope-exact path an owner's
`!cancel` in the thread uses (`signal_in_flight_task_for_scope`). A
channel running several thread sessions therefore no longer answers
`ambiguous_target` to a stop aimed at one of them. `cancel_turn` stays
channel-only, and its behavior is unchanged.
Details:
- Payload: `{ "type": "cancel_thread_turn", "channelId", "threadRootId",
"requestId" }`. `threadRootId` is required. It is parsed as an event id
and lowercased, the form scope keys use. A missing or malformed
`threadRootId` drops the frame without an answer, as a missing
`channelId` already does.
- It is a separate type rather than a field on `cancel_turn` because an
older harness reads only `channelId` from `cancel_turn`. Sent to such a
harness, a threaded `cancel_turn` could stop another thread's turn in
that channel. An older harness ignores the unknown `cancel_thread_turn`
type instead, and the sender times out. `cancel_turn` ignores any
`threadRootId`.
- Target: the thread's `Thread` scope. A threaded stop reaches the
channel's `Conversation` scope only when the channel is known to run as
one conversation: under the channel session policy, or in a channel
whose cached metadata says it is a DM. Under the thread policy, a
`Conversation` scope can also come from a metadata miss, because the DM
check fails closed, and that turn may belong to another thread.
- Answer: a `control_result` with `{ type: "cancel_thread_turn", status,
requestId }`. `status` is `sent` (the task received the signal; the turn
may not have ended yet) or `no_active_turn` (no turn ran there, or it
was already stopping). Both signal helpers now report `sent` only when
the task actually received the signal, not when its receiver was already
dropped.
`docs/nips/NIP-AO.md` now documents the control contract the code
implements:
- `cancel_turn` and `cancel_thread_turn`, with their fields and
statuses.
- The `control_result` telemetry frame, and the `batch` frame that can
carry it.
- The two other control types already handled, `switch_model` and
`publish_project_owner_announcements`, with their fields and results.
The relay subscription text is untouched.
This is one part of making Stop work for an agent that runs on another
of the owner's devices. Senders use `cancel_thread_turn` for threaded
conversations.
### Related issue
None found.
### Testing
- `cargo test -p buzz-acp`: all pass (1090 lib tests).
- Tests in `owner_control_command_tests`:
- `cancel_thread_turn_stops_only_that_thread`. Setup: two thread
sessions in one channel. Results:
- A stop with thread A's root, in uppercase, signals only A and answers
`sent`.
- A thread with no turn answers `no_active_turn`.
- A again, after its signal is spent, answers `no_active_turn`.
- A malformed, null or missing root gets no answer and signals nothing.
- A `cancel_turn` carrying thread B's root stays channel-wide: it
answers `ambiguous_target` and leaves B untouched.
-
`cancel_thread_turn_reaches_a_conversation_only_when_the_channel_is_one`:
- A conversation-scoped channel's one turn is stopped.
- A thread-policy channel where one thread fell back to a `Conversation`
scope: stops for the other thread never reach that turn.
- A task whose receiver was already dropped answers `no_active_turn`.
- `cargo clippy -p buzz-acp --all-targets -- -D warnings` and `cargo fmt
--check` are clean.
- The end-to-end macOS validation on this PR (issuecomment-7232802009)
ran before the move to `cancel_thread_turn`, so it covers the earlier
`cancel_turn` + `threadRootId` frame.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Gil Birman <gil@squareup.com>
Co-authored-by: g.s.opus <182de044fe08d24f64d005f425861956d29456fffb812544e93ed39df003b4d1@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
0 commit comments