fabro/lib/crates
fabro-sh-0530[bot] 79f89165f6
Wire end-to-end steering for running agents (#209)
## 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>
2026-05-05 15:34:16 -04:00
..
fabro-agent Wire end-to-end steering for running agents (#209) 2026-05-05 15:34:16 -04:00
fabro-api Wire end-to-end steering for running agents (#209) 2026-05-05 15:34:16 -04:00
fabro-auth refactor(api): unify secret metadata types 2026-04-29 20:26:13 -04:00
fabro-checkpoint Make git metadata sandbox-native 2026-04-27 21:43:15 -07:00
fabro-cli Wire end-to-end steering for running agents (#209) 2026-05-05 15:34:16 -04:00
fabro-client Wire end-to-end steering for running agents (#209) 2026-05-05 15:34:16 -04:00
fabro-config Move GitHub token permissions to [run.integrations.github.permissions] (#215) 2026-05-05 15:33:31 -04:00
fabro-core Cancel in-flight agent stages with CancellationToken (#211) 2026-05-05 09:54:22 -04:00
fabro-dev fix(docs): use MDX comment syntax for generated fences 2026-04-29 01:27:43 -04:00
fabro-devcontainer refactor(static): centralize env var names 2026-04-24 12:29:51 -04:00
fabro-dump Encode stage visits in run stage URLs (#206) 2026-05-05 08:27:11 -04:00
fabro-github refactor(error): drop String error shims and DisplayContains test traits 2026-05-01 19:35:22 -04:00
fabro-graphviz refactor: simplify Rust review cleanup 2026-05-02 15:41:17 -04:00
fabro-hooks feat(command): distinguish cancelled commands from timeouts 2026-04-30 22:45:37 -04:00
fabro-http refactor(static): centralize env var names 2026-04-24 12:29:51 -04:00
fabro-install feat(install): add sandbox provider step to web install wizard 2026-04-27 14:59:17 -07:00
fabro-interview Wire end-to-end steering for running agents (#209) 2026-05-05 15:34:16 -04:00
fabro-llm fix(llm): omit Anthropic thinking for forced tools 2026-05-05 13:02:29 -04:00
fabro-macros refactor(dev): simplify generated docs tooling 2026-04-24 18:41:00 -04:00
fabro-mcp fix(error): preserve source chains across workspace 2026-05-01 17:30:20 -04:00
fabro-model refactor(server): simplify model availability probes 2026-05-04 11:47:37 -04:00
fabro-oauth fix(error): preserve remaining error context 2026-05-02 10:51:15 -04:00
fabro-options-metadata refactor(dev): simplify generated docs tooling 2026-04-24 18:41:00 -04:00
fabro-proc refactor(static): centralize env var names 2026-04-24 12:29:51 -04:00
fabro-redact fix(redact): skip name fields to preserve sandbox identifiers 2026-05-03 19:57:55 -04:00
fabro-retro Cancel in-flight agent stages with CancellationToken (#211) 2026-05-05 09:54:22 -04:00
fabro-sandbox Cancel in-flight agent stages with CancellationToken (#211) 2026-05-05 09:54:22 -04:00
fabro-server Wire end-to-end steering for running agents (#209) 2026-05-05 15:34:16 -04:00
fabro-slack refactor: simplify auth and actor handling 2026-05-02 11:44:17 -04:00
fabro-spa feat(dev): gitignore embedded spa assets 2026-04-26 21:31:11 -04:00
fabro-static feat(server): validate Daytona API key scopes 2026-05-03 17:09:01 -04:00
fabro-store Wire end-to-end steering for running agents (#209) 2026-05-05 15:34:16 -04:00
fabro-telemetry refactor(static): centralize env var names 2026-04-24 12:29:51 -04:00
fabro-template refactor(async): lint std::process::Command across all targets 2026-04-12 13:35:57 -04:00
fabro-test fix(cli): bound server readiness probes 2026-05-02 20:13:18 -04:00
fabro-tracker fix(error): preserve remaining error context 2026-05-02 10:51:15 -04:00
fabro-types Wire end-to-end steering for running agents (#209) 2026-05-05 15:34:16 -04:00
fabro-util refactor(error): drop String error shims and DisplayContains test traits 2026-05-01 19:35:22 -04:00
fabro-validate refactor: simplify Rust review cleanup 2026-05-02 15:41:17 -04:00
fabro-vault refactor(api): unify secret metadata types 2026-04-29 20:26:13 -04:00
fabro-workflow Wire end-to-end steering for running agents (#209) 2026-05-05 15:34:16 -04:00