## Summary
This makes the advertised mid-run steering path real: users can send
append or interrupt steering messages through the API, CLI, and web UI,
and the worker delivers them to live API-mode agent sessions or buffers
them for the next session. The change adds the control protocol, session
interrupt machinery, workflow hub, server route/OpenAPI/client updates,
and UI feedback needed for the whole path.
### Plan Summary
- Add `SteerKind`/`run.steer` wire protocol and `POST /runs/{id}/steer`
- Deliver steers through subprocess JSONL or the in-process
`SteeringHub`
- Support append and interrupt behavior in agent sessions, with bounded
buffering and events
- Expose steering in the CLI/web UI and surface SSE toasts
## Flow
```mermaid
flowchart TB
UI["CLI / Web UI"] --> API["POST /runs/{id}/steer"]
API -->|"subprocess transport"| Control["Worker control JSONL"]
API -->|"in-process transport"| Hub["SteeringHub"]
Control --> Hub
Hub -->|"active API sessions"| Session["SessionControlHandle"]
Hub -->|"no active session"| Pending["Pending buffer"]
Pending -->|"first future API session"| Session
Session --> Agent["Session round loop"]
Agent --> Events["RunEvent stream"]
Events --> UI
```
## What changed and why
- Agent sessions now expose a lightweight `SessionControlHandle`, drain
steering at the top of each round, and use a replaceable round
cancellation token for interrupts. LLM waits are cancelled promptly,
while tool execution observes cancellation cooperatively so every
committed `tool_use` still gets a matching `tool_result`.
- `SteeringHub` owns active API session registration, broadcast
delivery, pending buffering, FIFO queue caps, and steering
lifecycle/drop events. A completion coordinator closes the
final-response race without introducing a workflow dependency into the
agent crate.
- The server route replaces the 501 stub, validates run state and
best-effort CLI-only steerability, and forwards through either
subprocess control JSONL or the in-process hub. OpenAPI and generated
clients now include the request type.
- The CLI and web UI can send append or interrupt steers. Run detail and
board views open the new composer, and shared SSE subscriptions now
support per-subscriber event callbacks so invalidation and steering
toasts can coexist on one EventSource.
## Review notes
- Steering actors stay on top-level `RunEvent.actor`; event props only
carry steering kind/drop metadata.
- Buffered steers replay as append messages to the first API session
that registers after an empty-active period. Per-stage targeting remains
out of scope.
- CLI-mode agent stages are still not steerable; the server returns a
best-effort 409 when all active agent stages are CLI-mode, while the
worker hub remains the authoritative safety net.
- No persistence or schema migration is required; active and pending
steering state is in memory.
- New tests focus on protocol round-trips, hub buffering/bounds, session
steering-loop behavior, SSE fanout, and basic server rejection paths.
⚒️ Generated with [Fabro](https://fabro.sh)
---------
Co-authored-by: Fabro <noreply@fabro.sh>
Co-authored-by: Bryan Helmkamp <bryan@brynary.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
11 KiB
Decouple Interrupts From Steering Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Split run interruption from steering message delivery while keeping steer interrupt=true as ergonomic sugar.
Architecture: run.interrupt becomes a standalone control/event path that cancels the active API-mode agent round and waits for later steering. run.steer becomes a plain message-injection path with no delivery kind. The existing combined user flow applies interrupt first, then steer, preserving user convenience without coupling the concepts in queue/event types.
Tech Stack: Rust workspace crates (fabro-agent, fabro-workflow, fabro-server, fabro-interview, fabro-api, fabro-client), OpenAPI, generated TypeScript API client, React web app, SSE run events.
Summary
Split steering message delivery from agent interruption. run.steer becomes a plain "user injected guidance" event with no kind; run.interrupt becomes a separate control/event path that cancels the active agent round. POST /runs/{id}/steer { interrupt: true } remains ergonomic sugar for "interrupt, then steer," but there is no standalone CLI interrupt command.
Standalone interrupts cancel the current active API-mode agent round, keep the stage's steering lease active, and wait at a steerable point until a later steer resumes the agent.
Key Changes
-
Public API:
- Add
POST /api/v1/runs/{id}/interruptwith202,404,409, and503behavior matching steer/cancel conventions. - Keep
POST /api/v1/runs/{id}/steer; keepinterrupt?: booleanas request convenience. - For
steer interrupt=true, require an active API-mode agent session and send one atomic worker-control operation that applies interrupt first, then enqueues the steer. - Non-interrupt steer may still buffer when no API session is active and no CLI agent is running.
- Regenerate Rust and TypeScript API clients after OpenAPI updates.
- Add
-
Control protocol and types:
- Replace
WorkerControlMessage::Steer { text, kind, actor }withSteer { text, actor }. - Add
WorkerControlMessage::Interrupt { actor }. - Add
WorkerControlMessage::InterruptThenSteer { text, actor }for the combined convenience path. The server must send this as one control envelope; do not implementsteer interrupt=trueas two independent enqueue operations. - Remove
SteerKindfromfabro-types,fabro-agent, workflow event payloads, and web client assumptions. - Keep existing CLI
fabro steer --interrupt; implement it through the existing steer API, not a new CLI command.
- Replace
-
Workflow/session behavior:
- Split
SessionControlHandleinto plainsteer(text, actor)and plaininterrupt(actor). - Add an explicit agent-side
waiting_for_steerstate, guarded by the same control state as the steering queue. - Steering enqueues text, clears
waiting_for_steer, and wakes the session. - Interrupt cancels the current round token and, when the steering queue is empty, sets
waiting_for_steerso the session cannot immediately start another LLM round with unchanged context. - Duplicate pure interrupts while already
waiting_for_steerare idempotent: accept them, emit anotherrun.interrupt, keep the session waiting, and do not enqueue synthetic steering. - If an interrupt cancels an LLM stream or tool round without queued steering, the session waits without closing/deactivating its steering lease; terminal run cancellation still wins immediately.
- If interrupt and steer are applied together, the steer resumes the waiting/next round immediately.
- Terminal run cancellation must wake/break any
waiting_for_steerwait and return the existing cancellation error path. - Update the natural-completion close-the-door path so the activation lease is kept alive when the steering queue is nonempty or
waiting_for_steeris true.CompletionCoordinator,ActivationLease::release_if_queue_empty, andSessionControlHandleshould expose/use a single "has pending control work" predicate instead of checking queue emptiness alone.
- Split
-
Events:
- Add top-level persisted
run.interruptwithactorin the envelope and empty properties. - Add top-level persisted
run.steerwithactorin the envelope andproperties.text. - Keep
agent.steering.injected, but removekind; it means the steer actually entered agent history. - Keep
agent.steer.bufferedandagent.steer.dropped, but removekindfrom buffered. - Update run-event conversion, stored fields, docs, SSE invalidation, and toast logic for the simplified payloads.
- Add top-level persisted
-
Event ownership and ordering:
- The worker-side control handler /
SteeringHubis the single source of truth for persistedrun.interruptandrun.steer; API handlers only emit these events indirectly after the live worker accepts the control envelope. - A failed or timed-out control-channel request must not emit
run.interruptorrun.steer. - For
InterruptThenSteer, persisted order must berun.interrupt, thenrun.steer, then lateragent.steering.injectedonly when the text is drained into agent history.
- The worker-side control handler /
Protocol vs Events
Worker-control messages are transport commands, not persisted RunEvent names. run.interrupt_then_steer exists only as a worker-control envelope for atomic delivery of the combined convenience path and must never be emitted as a persisted run event. The only persisted run-level event names introduced here are run.interrupt and run.steer.
API Response Matrix
| Run state | POST /steer |
POST /steer { interrupt: true } |
POST /interrupt |
|---|---|---|---|
| Active API-mode session | 202 accepted; emits run.steer; later agent.steering.injected |
202 accepted atomically; emits run.interrupt, then run.steer |
202 accepted; emits run.interrupt |
Active API-mode session already waiting_for_steer |
202 accepted; emits run.steer; clears wait and later emits agent.steering.injected |
202 accepted atomically; emits run.interrupt, then run.steer; clears wait |
202 accepted idempotently; emits run.interrupt; remains waiting |
| No active API session, no active CLI agent | 202 accepted; emits run.steer, then agent.steer.buffered |
409 no_active_api_session |
409 no_active_api_session |
| Active CLI-only agent stages | 409 cli_agent_not_steerable |
409 cli_agent_not_steerable |
409 cli_agent_not_steerable |
| Blocked on interview/question | 409 use_answer_endpoint |
409 use_answer_endpoint |
409 use_answer_endpoint |
| Terminal run | 409 run_not_steerable |
409 run_not_steerable |
409 run_not_interruptible |
| Missing live worker channel | 503 worker_control_unavailable |
503 worker_control_unavailable |
503 worker_control_unavailable |
| Archived run | Existing archived-run rejection response from reject_if_archived |
Existing archived-run rejection response from reject_if_archived |
Existing archived-run rejection response from reject_if_archived |
Implementation Checklist
- OpenAPI/API clients: add
/runs/{id}/interrupt, keepSteerRunRequest.interrupt, regeneratefabro-api,fabro-clientusage, and TypeScript API client models. - Server route and transport: add interrupt handler, add
RunAnswerTransport::interrupt, addRunAnswerTransport::interrupt_then_steer, enforce the API response matrix, and ensure combined steer uses one control operation. - Worker protocol: simplify
run.steer, addrun.interrupt, addrun.interrupt_then_steer, and update subprocess/in-process dispatch. - Agent session state: replace
SteerKindqueue items with plain text+actor, addwaiting_for_steer, wake on steer, block after pure interrupt, make duplicate interrupts idempotent while waiting, and break wait on terminal cancellation. - Natural-completion lease safety: update
CompletionCoordinator,ActivationLease::release_if_queue_empty, andSessionControlHandleso close-the-door keeps the lease alive when either the queue is nonempty orwaiting_for_steeris true. - Steering hub behavior: expose plain
deliver_steer,interrupt, andinterrupt_then_steer; emit accepted control events in the required order; keep buffering/dropping only for steering text. - Events/schema/store/web: add
run.interruptandrun.steer, simplifyagent.steering.injectedandagent.steer.buffered, update stored fields, docs, run-state projections, SSE invalidation, and toasts. - Docs: update internal event docs, public API reference, CLI docs for
fabro steer --interrupt, and steering docs to explain interrupt as separate control flow. - Verification: run the Rust and web test commands listed below, plus formatting and clippy.
Test Plan
fabro-interviewworker-control envelope tests: JSON round-trip tests for transport-onlyrun.interrupt, simplifiedrun.steer, and transport-onlyrun.interrupt_then_steerpreservingtextandactor.fabro-types/fabro-apipersisted event tests:run.interruptandrun.steerserialize as persistedRunEvents; no persisted event namedrun.interrupt_then_steerexists.fabro-agent: unit tests for plain steer injection, LLM-stream interrupt enteringwaiting_for_steer, tool-round interrupt enteringwaiting_for_steer, pure interrupt racing with a no-tool natural completion without releasing the lease, later steer wake-up, duplicate interrupt while waiting, interrupt-plus-steer resuming without an extra wait, and terminal cancel breaking the wait.fabro-workflow: steering hub tests for buffering plain steers, dropping plain steers, broadcasting interrupts to active sessions, and preserving interrupt-before-steer ordering.fabro-server: handler tests for/interrupt,steer interrupt=true, the full API response matrix, missing worker channel, CLI-only conflict, terminal/blocked conflicts, and stale activation/deactivation behavior.fabro-clirunner/subprocess bridge: worker-control line handler tests for simplifiedrun.steer,run.interrupt, andrun.interrupt_then_steer.fabro-storeand run-event tests: projection ignores top-levelrun.interrupt/run.steerexcept where explicitly tracked;agent.session.activatedremains the provider-used source.- Web tests: update run-event invalidation and toast assertions for
run.interrupt,run.steer, simplifiedagent.steering.injected, and simplifiedagent.steer.buffered. - Verification commands:
cargo build -p fabro-apicd lib/packages/fabro-api-client && bun run generatecargo nextest run --workspacecd apps/fabro-web && bun test && bun run typecheckcargo +nightly-2026-04-14 fmt --check --allcargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings
Assumptions
- Event names are exactly
run.interruptandrun.steer. - Standalone interrupt is API-only for now; no
fabro interruptCLI command and no new standalone web button are required. - A pure interrupt is not a failure, pause, or cancellation of the run; it is a mid-stage wait point that resumes only when steering arrives or the run is terminally cancelled.
- Non-interrupt steering keeps the current buffering behavior, but interrupt steering does not buffer the interrupt portion when no active API session exists.
- Duplicate pure interrupts while already waiting are idempotent
202responses that emit another persistedrun.interruptand leave the wait state unchanged.