## Summary
Adds the server-side run pairing surface for joining one active API-mode
agent session, sending pair messages, reading a compact transcript, and
ending pairing explicitly before workflow release continues.
This PR wires the feature end to end:
- adds OpenAPI paths and shared `fabro-types` DTOs for pair lifecycle,
messages, transcript entries, and run event details
- adds typed `RunEvent` variants for pair lifecycle and pair-scoped
user/system messages
- extends the workflow steering hub and agent session drain path with
typed pair control items, single-target validation, pair parking, and
pair end/resume behavior
- extends worker JSONL control and server transports for pair
start/message/end while preserving existing
steer/interrupt/answer/cancel behavior
- adds Axum handlers for `/api/v1/runs/{id}/pair`, pair messages, pair
transcript, and `/api/v1/runs/{id}/events/{seq}`
- adds `fabro-client` helpers for the new endpoints
## Notes
The subprocess path does not add a bidirectional worker ack channel in
this PR. Instead, the HTTP pair handlers only return lifecycle/message
success after the corresponding durable runtime event is observed, so
mpsc enqueue success alone is not treated as API success.
The plan checklist in
`docs/superpowers/plans/2026-05-18-server-side-run-pairing-api-events.md`
is included with that distinction left visible.
## Verification
- `cargo build -p fabro-api`
- `cargo check -p fabro-api -p fabro-client -p fabro-agent -p
fabro-workflow -p fabro-interview -p fabro-server`
- `cargo +nightly-2026-04-14 fmt --check --all`
- `cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D
warnings`
- `cargo nextest run -p fabro-api pair
run_event_round_trips_pair_lifecycle_events
run_event_round_trips_agent_pair_messages`
- `cargo nextest run -p fabro-workflow pair`
- `cargo nextest run -p fabro-interview pair`
- `cargo nextest run -p fabro-server pair
subprocess_answer_transport_pair_commands_enqueue_control_messages steer
interrupt`
34 KiB
Server-Side Run Pairing API And Events 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: Add server-side run pairing APIs and typed run events so a user can join one active API-mode workflow agent session, exchange multiple messages, inspect a compact transcript, and explicitly end pairing before the workflow resumes.
Architecture: Pairing is run-native, not MCP-native. The HTTP API is resource-shaped under /api/v1/runs/{id}/pair, runtime control extends the existing steering/session-control path, and observation is projected from durable typed RunEvents rather than a new store. The v1 pair API is single-target, synchronously confirms pair start/end at the runtime boundary, and uses message for user input, never turn, because pair messages are inputs inside an open collaboration mode, not bounded request/response execution units.
Tech Stack: Rust, Axum, OpenAPI/progenitor, fabro-types, fabro-api, fabro-client, fabro-server, fabro-workflow, fabro-agent, fabro-store, cargo nextest.
Scope
In scope:
- Server-side HTTP API for pair lifecycle, pair messages, compact transcript, and a generic run-event detail endpoint.
- Typed pair-related
RunEventvariants and event conversion/storage metadata. - Runtime behavior for one selected API-mode agent session: start pairing, park on natural completion while paired, accept pair messages, and resume after explicit end.
- Rust client convenience methods for the new API.
Out of scope:
- MCP tool surface.
- Frontend/UI changes.
- Removing or refactoring the existing
/api/v1/sessionsAPI. - Non-API-mode pairing for ACP/CLI agent backends.
- Multi-target pairing. It can be added later with explicit fan-out semantics, but v1 must never broadcast pair messages by default.
Contract Decisions
- Single-target v1:
POST /api/v1/runs/{id}/pairrequires a target selector copied fromGET /api/v1/runs/{id}/pair. The server must not pair every active target automatically. - Synchronous lifecycle confirmation:
POST /pairwaits for the runtime to install pair mode for the selected target and returns200withstatus: "active".DELETE /pair/{pair_id}waits for the runtime to exit pair mode and returns200withstatus: "ended". - Small state machine:
PairStatusis onlyactive,ended, orfailed. There is no publicrequestedorendingstate and no timeout-based read-side reconciliation helper. - Event-backed observation: Pair records and transcript rows are reconstructed from durable run events. Lifecycle events are run-scoped; conversation effects are agent/session-scoped.
- No duplicate status surfaces:
PairRecord.statusis the source of truth for lifecycle.PairTargetdoes not carry its own lifecycle status. - No new session capability: Pairing uses the existing API-mode steering-capable session control surface. Do not add
SessionCapability::Pairunless a future backend supports steering but cannot support pairing. - Simple GET status:
GET /pairreturnsrun_id,current_pair, and availabletargets. It does not expose a separatepairableboolean or reason enum; clients can derive pairability fromcurrent_pair == null && targets.length > 0. - Transcript stays in v1: The transcript endpoint remains pair-scoped because it is core to pairing. It is a compact projection over
RunEvents and uses source event sequence cursors. - Generic details: Pair transcript entries point to
GET /api/v1/runs/{id}/events/{seq}for full detail. There is no pair-specific detail endpoint in v1.
Public API Contract
Add these paths to docs/public/api-reference/fabro-api.yaml, regenerate fabro-api, and add fabro-client convenience methods.
Shared Types
PairId
type: string
description: Durable run pair identifier.
example: 01HZX6M29F1CD5YYMHT1F5D7WQ
PairMessageId
type: string
description: Durable pair message identifier.
example: 01HZX6M4D7Y1QW0Q0P6V8Z4DR5
PairStatus
type: string
enum: [active, ended, failed]
Status meaning:
active: the runtime installed pair mode for the selected target, recordedrun.pair.started, and recorded thehuman_joinedsystem message inside that pair window.ended: the runtime exited pair mode, or the paired run/session ended, and recordedrun.pair.ended.failed: a pair that was already active ended abnormally and recordedrun.pair.failed.
PairTargetSelector
{
"stage_id": "code@1",
"agent_session_id": "ses_01"
}
Required fields:
stage_idagent_session_id
Both fields are required even if agent_session_id is unique within a run. stage_id is a stale-client cross-check so the server can reject a request when the client selected a session from one active stage but submits a selector for another.
PairTarget
{
"stage_id": "code@1",
"node_id": "code",
"node_label": "Code",
"visit": 1,
"agent_session_id": "ses_01",
"provider": "openai",
"model": "gpt-5.3"
}
Required fields:
stage_idnode_idnode_labelvisitagent_session_id
Nullable/optional fields:
providermodel
Use targets only for available target lists. Use singular target on PairRecord so v1 cannot accidentally imply multi-target pairing. PairTarget intentionally has no status field; the parent PairRecord.status is the lifecycle source of truth. Existing raw run event envelopes may still use top-level session_id.
PairRecord
{
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"run_id": "01HZX6M0P7SE4VJ9Y3X2B8E9QF",
"status": "active",
"started_at": "2026-05-18T12:00:01Z",
"ended_at": null,
"failure_reason": null,
"target": {
"stage_id": "code@1",
"node_id": "code",
"node_label": "Code",
"visit": 1,
"agent_session_id": "ses_01",
"provider": "openai",
"model": "gpt-5.3"
}
}
Required fields:
pair_idrun_idstatusstarted_attarget
Nullable fields:
ended_atfailure_reason
RunPairStatusResponse
{
"run_id": "01HZX6M0P7SE4VJ9Y3X2B8E9QF",
"current_pair": null,
"targets": [
{
"stage_id": "code@1",
"node_id": "code",
"node_label": "Code",
"visit": 1,
"agent_session_id": "ses_01",
"provider": "openai",
"model": "gpt-5.3"
}
]
}
Required fields:
run_idtargets
Nullable field:
current_pair
PairStartRequest
{
"target": {
"stage_id": "code@1",
"agent_session_id": "ses_01"
}
}
Required fields:
targettarget.stage_idtarget.agent_session_id
The target selector must match exactly one active target returned by GET /pair.
PairMessageRequest
{
"text": "Can you inspect the failing test?",
"client_message_id": "optional-correlation-id"
}
Validation:
textis required.textmust be trimmed non-empty.textmax length is8192.client_message_idis optional and echoed if present.client_message_idis not a deduplication key in v1; it is a caller correlation field only.
PairMessageRecord
{
"message_id": "01HZX6M4D7Y1QW0Q0P6V8Z4DR5",
"client_message_id": "optional-correlation-id",
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"run_id": "01HZX6M0P7SE4VJ9Y3X2B8E9QF",
"target": {
"stage_id": "code@1",
"agent_session_id": "ses_01"
},
"text": "Can you inspect the failing test?",
"accepted_at": "2026-05-18T12:01:00Z"
}
Required fields:
message_idpair_idrun_idtargettextaccepted_at
Nullable field:
client_message_id
GET /api/v1/runs/{id}/pair
Returns the active pair if any and all currently active targets eligible for pairing.
Success 200: RunPairStatusResponse.
Example:
{
"run_id": "01HZX6M0P7SE4VJ9Y3X2B8E9QF",
"current_pair": {
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"run_id": "01HZX6M0P7SE4VJ9Y3X2B8E9QF",
"status": "active",
"started_at": "2026-05-18T12:00:01Z",
"ended_at": null,
"failure_reason": null,
"target": {
"stage_id": "code@1",
"node_id": "code",
"node_label": "Code",
"visit": 1,
"agent_session_id": "ses_01",
"provider": "openai",
"model": "gpt-5.3"
}
},
"targets": [
{
"stage_id": "review@1",
"node_id": "review",
"node_label": "Review",
"visit": 1,
"agent_session_id": "ses_02",
"provider": "openai",
"model": "gpt-5.3"
}
]
}
Errors:
404ErrorResponse: run not found.
POST /api/v1/runs/{id}/pair
Starts pairing with one selected active pairable API-mode agent target.
Request body: PairStartRequest.
{
"target": {
"stage_id": "code@1",
"agent_session_id": "ses_01"
}
}
Success 200: PairRecord with status: "active" after the runtime installs pair mode for the target, records run.pair.started, queues the human_joined system message, and requests interruption/parking.
The successful response does not mean the model has produced a follow-up assistant message. It means the selected runtime session is now in pair mode and will not naturally complete the workflow stage until pairing ends.
Example:
{
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"run_id": "01HZX6M0P7SE4VJ9Y3X2B8E9QF",
"status": "active",
"started_at": "2026-05-18T12:00:01Z",
"ended_at": null,
"failure_reason": null,
"target": {
"stage_id": "code@1",
"node_id": "code",
"node_label": "Code",
"visit": 1,
"agent_session_id": "ses_01",
"provider": "openai",
"model": "gpt-5.3"
}
}
Errors:
400blank or missing target selector.404run not found.409withcode: "run_not_pairable"when the run is not running, is blocked, is terminal, has no active API session, or only has non-pairable active agents.409withcode: "already_paired"when a current pair exists.409withcode: "pair_target_not_active"when the requested target no longer exists or is not active.409withcode: "pair_target_not_pairable"when the target exists but is no longer an active API-mode steering-capable target.503withcode: "worker_control_unavailable"when the live worker control channel is missing, closed, times out before confirmation, or cannot return a runtime-level confirmation.
GET /api/v1/runs/{id}/pair/{pair_id}
Returns a current or historical pair reconstructed from durable events.
Success 200: PairRecord.
Errors:
404withcode: "pair_not_found"when no pair with that id exists for the run.404run not found.
DELETE /api/v1/runs/{id}/pair/{pair_id}
Ends that exact pair. The path pair_id is a stale-write guard.
Request body: none.
Success 200: PairRecord with status: "ended" after the runtime exits pair mode, queues the human_left system message when the target session is still present, and records run.pair.ended.
Example:
{
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"run_id": "01HZX6M0P7SE4VJ9Y3X2B8E9QF",
"status": "ended",
"started_at": "2026-05-18T12:00:01Z",
"ended_at": "2026-05-18T12:05:00Z",
"failure_reason": null,
"target": {
"stage_id": "code@1",
"node_id": "code",
"node_label": "Code",
"visit": 1,
"agent_session_id": "ses_01",
"provider": "openai",
"model": "gpt-5.3"
}
}
Errors:
404run not found.404withcode: "pair_not_found".409withcode: "pair_not_current"when the pair exists but is not the current pair.409withcode: "pair_not_active"when the pair is already ended or failed.503withcode: "worker_control_unavailable"when the live worker control channel is missing, closed, times out before confirmation, or cannot return a runtime-level confirmation.
POST /api/v1/runs/{id}/pair/{pair_id}/messages
Sends one paired user message to the active target. This does not create a turn and does not stream.
Request: PairMessageRequest.
{
"text": "Can you inspect the failing test?",
"client_message_id": "optional-correlation-id"
}
Success 202: PairMessageRecord.
202 means the active target runtime accepted the message into the paired session queue and recorded agent.pair.user_message. If the target is gone, the queue is full, the pair is not active, or the runtime rejects the message, the API must fail the request instead of returning an accepted message that can later be silently dropped.
{
"message_id": "01HZX6M4D7Y1QW0Q0P6V8Z4DR5",
"client_message_id": "optional-correlation-id",
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"run_id": "01HZX6M0P7SE4VJ9Y3X2B8E9QF",
"target": {
"stage_id": "code@1",
"agent_session_id": "ses_01"
},
"text": "Can you inspect the failing test?",
"accepted_at": "2026-05-18T12:01:00Z"
}
Errors:
400blanktextor other semantic input error.404run not found.404withcode: "pair_not_found".409withcode: "pair_not_current".409withcode: "pair_not_active".409withcode: "pair_target_not_active"when the paired target session is gone.409withcode: "pair_message_not_accepted"when the active runtime rejects the message, including queue-cap rejection.503withcode: "worker_control_unavailable".
GET /api/v1/runs/{id}/pair/{pair_id}/transcript
Query parameters:
since_seq: integer, minimum1, default1.limit: integer, minimum1, maximum1000, default100.
Returns a compact projection over durable run events. Exclude deltas and full tool output.
Success 200:
{
"data": [
{
"kind": "user_message",
"seq": 42,
"event_id": "01960d0c-5d16-7d6e-8f61-9fd6f4a532b5",
"ts": "2026-05-18T12:01:00Z",
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"target": {
"stage_id": "code@1",
"node_id": "code",
"node_label": "Code",
"visit": 1,
"agent_session_id": "ses_01"
},
"message_id": "01HZX6M4D7Y1QW0Q0P6V8Z4DR5",
"client_message_id": "optional-correlation-id",
"text": "Can you inspect the failing test?"
},
{
"kind": "assistant_message",
"seq": 44,
"event_id": "01960d0d-0000-7000-8000-000000000000",
"ts": "2026-05-18T12:01:12Z",
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"target": {
"stage_id": "code@1",
"node_id": "code",
"node_label": "Code",
"visit": 1,
"agent_session_id": "ses_01"
},
"text": "I found one failing test.",
"model": {
"provider": "openai",
"model_id": "gpt-5.3",
"speed": null
},
"tool_call_count": 0
},
{
"kind": "tool_call",
"seq": 45,
"event_id": "01960d0e-0000-7000-8000-000000000000",
"ts": "2026-05-18T12:01:20Z",
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"target": {
"stage_id": "code@1",
"node_id": "code",
"node_label": "Code",
"visit": 1,
"agent_session_id": "ses_01"
},
"tool_call_id": "call_7",
"tool_name": "shell",
"status": "completed",
"summary": "Ran cargo nextest; one test failed.",
"is_error": false,
"truncated": true,
"detail_ref": {
"seq": 45,
"tool_call_id": "call_7"
}
}
],
"meta": {
"next_since_seq": 46,
"has_more": false
}
}
Transcript entry variants:
user_message:kind,seq,event_id,ts,pair_id,target,message_id, nullableclient_message_id,text.system_message:kind,seq,event_id,ts,pair_id,target,system_message_kind,text.assistant_message:kind,seq,event_id,ts,pair_id,target,text,model,tool_call_count.tool_call:kind,seq,event_id,ts,pair_id,target,tool_call_id,tool_name,status,summary,is_error,truncated,detail_ref.error:kind,seq,event_id,ts,pair_id,target,message,detail_ref.warning:kind,seq,event_id,ts,pair_id,target,warning_kind,message,detail_ref.
Projection rules:
- Include
agent.pair.user_messageaskind: "user_message". - Include
agent.pair.system_messageaskind: "system_message". - The pair window starts at
run.pair.started.seqand ends atrun.pair.ended.seqorrun.pair.failed.seq, inclusive. For active pairs, the window has no upper bound. - Include
agent.message,agent.tool.started,agent.tool.completed,agent.error, andagent.warningonly when the source event sequence falls inside the pair window and itssession_idmatches the pair target. - Exclude
agent.text.delta,agent.reasoning.delta, andagent.tool.output.delta. - For
agent.tool.started, usestatus: "started". - For
agent.tool.completed, usestatus: "completed". - Tool summaries must be deterministic and compact: include tool name, error status, and a short human-readable preview of arguments/output without embedding full output.
next_since_seqis the highest scanned source event sequence plus1, not the last returned transcript entry plus1. This lets clients advance past excluded delta/output events without polling the same range forever.
Errors:
400invalid query parameter.404run not found.404withcode: "pair_not_found".
GET /api/v1/runs/{id}/events/{seq}
Returns one stored run event by source event sequence. Pair transcript detail_ref.seq points here.
Query parameters:
max_content_length: integer, minimum1, maximum200000, default20000.
Success 200: RunEventDetailResponse.
{
"event": {
"seq": 45,
"id": "01960d0e-0000-7000-8000-000000000000",
"ts": "2026-05-18T12:01:20Z",
"run_id": "01HZX6M0P7SE4VJ9Y3X2B8E9QF",
"event": "agent.tool.completed",
"actor": null,
"session_id": "ses_01",
"node_id": "code",
"node_label": "Code",
"stage_id": "code@1",
"tool_call_id": "call_7"
},
"properties": {
"tool_name": "shell",
"tool_call_id": "call_7",
"is_error": false,
"visit": 1
},
"content": {
"kind": "tool_output",
"value": "..."
},
"truncated": false,
"redacted": false,
"max_content_length": 20000
}
Detail rules:
- Lookup is by
seqonly in v1. Do not addevent_idlookup until a concrete caller needs it. - The response must not include an untruncated raw event containing content-bearing
properties.output, tool arguments, assistant text, or error details. - Keep event identity and envelope metadata in
event. - Keep non-content event properties in
properties. - Put content-bearing fields in
content, with the same truncation and redaction rules applied consistently. truncatedreports whether returned content was shortened because ofmax_content_length.redactedreports whether secret redaction changed the returned content.
Errors:
400invalidmax_content_length.404run not found.404withcode: "event_not_found"when the sequence does not exist for the run.
Pair Lifecycle State Machine
The lifecycle is synchronous at the API/runtime boundary and has no requested or ending state.
| Current state | Trigger | Next state | Required durable event | API behavior |
|---|---|---|---|---|
| none | Runtime confirms pair.start for selected target |
active | run.pair.started, then agent.pair.system_message { kind: "human_joined" } |
POST /pair returns 200 with status: "active" |
| none | Target missing, target not pairable, run not pairable, worker unavailable, or runtime rejects start | none | none | POST /pair returns the documented 4xx or 503 |
| active | Runtime accepts paired user message | active | agent.pair.user_message |
POST /messages returns 202 |
| active | Runtime confirms user-requested pair end | ended | agent.pair.system_message { kind: "human_left" }, then run.pair.ended { reason: "user_requested" } |
DELETE /pair/{pair_id} returns 200 with status: "ended" |
| active | Run ends or target session ends outside explicit pair end | ended | run.pair.ended with reason run_ended or session_ended |
GET /pair/{pair_id} returns ended |
| active | Worker or runtime fails after pair is active | failed | run.pair.failed |
GET /pair/{pair_id} returns failed |
| ended | Any lifecycle command | ended | none | mutating commands return 409 pair_not_active |
| failed | Any lifecycle command | failed | none | mutating commands return 409 pair_not_active |
Lifecycle rules:
POST /pairmust not return success until the runtime has applied pair mode, recordedrun.pair.started, queuedhuman_joined, and requested interruption/parking.DELETE /pair/{pair_id}must not return success until the runtime has ended pair mode and recordedrun.pair.ended.human_joinedandhuman_leftsystem messages sit inside the pair window, betweenrun.pair.startedandrun.pair.ended.- Pair read handlers reconstruct state by reading durable pair events in sequence order. They must not write timeout-derived failure events based only on absence of
run.pair.ended. run.pair.endedandrun.pair.failedare mutually exclusive terminal events. Clean termination emitsrun.pair.ended; abnormal termination emitsrun.pair.failed; do not emit both for the same pair.- Worker-exit handling, run-finalization handling, or runtime error handling records
run.pair.failedorrun.pair.endedat the moment that failure/end is observed. - Repeated end on an already terminal pair returns
409 pair_not_active, not a second terminal event.
Event Contract
All events are typed RunEvents. Keep actor, session, node, stage, and tool identity in existing top-level envelope fields.
Canonical envelope fields:
{
"id": "01960d0c-5d16-7d6e-8f61-9fd6f4a532b5",
"ts": "2026-05-18T12:00:00Z",
"run_id": "01HZX6M0P7SE4VJ9Y3X2B8E9QF",
"event": "run.pair.started",
"actor": {
"kind": "user",
"identity": {
"issuer": "dev",
"subject": "alice"
},
"login": "alice",
"auth_method": "dev_token"
},
"properties": {}
}
Run-Level Events
run.pair.started
Envelope:
actor: user principal that requested start.
Properties:
{
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"target": {
"stage_id": "code@1",
"node_id": "code",
"node_label": "Code",
"visit": 1,
"agent_session_id": "ses_01",
"provider": "openai",
"model": "gpt-5.3"
}
}
run.pair.ended
Envelope:
actor: user principal when user-requested; omitted for system/runtime end.
Properties:
{
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"reason": "user_requested"
}
End reasons:
user_requestedrun_endedsession_ended
run.pair.failed
Envelope:
actor: omitted unless failure is directly tied to a user request that was accepted and then failed while applying.
Properties:
{
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"reason": "worker_gone",
"message": "The workflow worker exited while pairing was active."
}
Failure reasons:
worker_goneruntime_failedsession_failedrun_failed
Agent-Target Events
agent.pair.user_message
Envelope:
session_id: target API-mode agent session id.node_id: target node id.node_label: target node label.stage_id: target stage id.actor: user principal that sent the message.
Properties:
{
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"message_id": "01HZX6M4D7Y1QW0Q0P6V8Z4DR5",
"client_message_id": "optional-correlation-id",
"text": "Can you inspect the failing test?",
"visit": 1
}
client_message_id is omitted when absent.
agent.pair.system_message
Envelope:
session_id: target API-mode agent session id.node_id: target node id.node_label: target node label.stage_id: target stage id.
Properties:
{
"pair_id": "01HZX6M29F1CD5YYMHT1F5D7WQ",
"kind": "human_joined",
"text": "A human has joined this workflow run for live pairing. Wait for their next message before continuing.",
"visit": 1
}
Kinds:
human_joinedhuman_left
Required system message text:
human_joined:A human has joined this workflow run for live pairing. Wait for their next message before continuing.human_left:The human has ended live pairing. Continue autonomously with the workflow.
There is no run.pair.user_message, agent.pair.activated, agent.pair.deactivated, or agent.pair.message.dropped event in v1. Accepted pair messages must be delivered to the selected active target runtime queue, or the message endpoint must fail.
Existing events that remain unchanged:
agent.messageagent.tool.startedagent.tool.completedagent.erroragent.warning- existing steering events
Implementation Units
Unit 1: Shared Types And OpenAPI
Files:
- Modify
docs/public/api-reference/fabro-api.yaml. - Modify or create
lib/crates/fabro-types/src/pair.rsand re-export fromlib/crates/fabro-types/src/lib.rs. - Modify
lib/crates/fabro-api/build.rs. - Add tests under
lib/crates/fabro-api/tests/.
Steps:
- Add shared pair schemas and endpoints to OpenAPI with the exact request/response shapes above.
- Add
PairId,PairMessageId,PairStatus,PairTargetSelector,PairTarget,PairRecord,RunPairStatusResponse,PairStartRequest,PairMessageRequest,PairMessageRecord, transcript entry types, andRunEventDetailResponsetofabro-types. - Leave
SessionCapabilityunchanged. Existingsteercapability remains the active API-mode control signal that pair target discovery uses. - Add
with_replacement(...)mappings infabro-api/build.rsfor shared pair types and the generic event detail response. - Run
cargo build -p fabro-apito regenerate API code. - Add type identity and JSON parity tests for pair ids, status enums, selectors, pair records, message records, transcript responses, and event detail responses.
Unit 2: Typed Pair Events
Files:
- Modify
lib/crates/fabro-types/src/run_event/mod.rs. - Modify
lib/crates/fabro-types/src/run_event/agent.rs. - Modify
lib/crates/fabro-types/src/run_event/run.rs. - Modify
lib/crates/fabro-workflow/src/event/events.rs. - Modify
lib/crates/fabro-workflow/src/event/names.rs. - Modify
lib/crates/fabro-workflow/src/event/convert.rs. - Modify
lib/crates/fabro-workflow/src/event/stored_fields.rs.
Steps:
- Add props structs and
EventBodyvariants forrun.pair.started,run.pair.ended,run.pair.failed,agent.pair.user_message, andagent.pair.system_message. - Add matching internal
Eventvariants. - Update
event_name()with exact dot-notation names. - Update
event_body_from_event()with JSON properties matching the event contract. - Update
stored_event_fields()so actor, session, node, stage, and tool identity live in the envelope, not duplicated in properties. - Add tests for event names, serialized wire shape, actor lifting, session/stage envelope mapping, and
visitpreservation.
Unit 3: Runtime Pair Control
Files:
- Modify
lib/crates/fabro-agent/src/session.rs. - Modify
lib/crates/fabro-agent/src/types.rsonly if message conversion needs a new internal variant; otherwise keep using existingMessage::UserandMessage::System. - Modify
lib/crates/fabro-workflow/src/steering_hub.rs. - Modify
lib/crates/fabro-workflow/src/handler/llm/activation_lease.rs. - Modify
lib/crates/fabro-workflow/src/handler/llm/api.rs.
Steps:
- Replace the text-only steering queue internals with typed control items while preserving existing steering public helpers.
- Track one active pair per run and one selected target per pair.
- Pair user messages must append
Message::Userand emitagent.pair.user_message. - Pair system messages must append
Message::Systemand emitagent.pair.system_message. - Pair start must validate the exact selected target, enable pair mode, record
run.pair.started, queuehuman_joined, request interruption/parking, and return runtime confirmation. - Pair message must record
agent.pair.user_messageonce for the selected target after queue acceptance. - Pair end must queue
human_left, disable pair mode, recordrun.pair.ended, and return runtime confirmation. - While pair is active, no-tool natural completion must stay parked instead of releasing the stage.
- After pair end, normal autonomous completion/release behavior must resume.
- Pair start requires an active API-mode steering-capable target; ACP/CLI-only agents are not pairable.
Unit 4: Worker Control Transport
Files:
- Modify
lib/crates/fabro-interview/src/control_protocol.rs. - Modify
lib/crates/fabro-cli/src/commands/run/runner.rs. - Modify
lib/crates/fabro-server/src/server.rs.
Steps:
- Add
WorkerControlMessagevariants forpair.start,pair.message, andpair.end. - Add constructors on
WorkerControlEnvelope. - Extend worker control so pair start and end return runtime-level confirmed success or typed rejection; mpsc enqueue success alone must not satisfy pair lifecycle API success.
- Update worker control-line handling to call the workflow pair control methods and send back typed accept/reject results.
- Extend
RunAnswerTransportwithstart_pair,send_pair_message, andend_pair. - Preserve existing
steer,interrupt,interrupt_then_steer,answer, andcancelbehavior. - Add tests proving subprocess transport returns confirmed results for start/end, accepted results for message enqueue, and maps runtime rejections to documented API errors.
Unit 5: Server API Handlers
Files:
- Add
lib/crates/fabro-server/src/server/handler/pair.rs. - Add or modify the existing run event handler for
GET /api/v1/runs/{id}/events/{seq}. - Modify
lib/crates/fabro-server/src/server/handler/mod.rs. - Modify
lib/crates/fabro-server/src/server.rs. - Modify
lib/crates/fabro-client/src/client.rs.
Steps:
- Implement pair routes and merge them into the existing server router.
- Implement
GET /api/v1/runs/{id}/events/{seq}under the existing run internals/event handler surface. - Add live
ManagedRunstate for richer active API target metadata. - Implement active pair-eligible target enumeration from live
ManagedRunstate. - Implement exact target selection; do not default to all active targets when multiple targets exist.
- Implement pair lifecycle reconstruction from durable events without read-time timeout reconciliation.
- Reuse existing run gates: archived rejection, blocked rejection, terminal rejection, and worker-control unavailable handling.
- Return the documented
ErrorResponse.codevalues for all pair conflicts. - Add
fabro-clientmethods for get pair status, start pair, get pair by id, end pair, send pair message, get transcript, and get run event detail.
Unit 6: Transcript Projection And Event Detail
Files:
- Add projection helpers in
lib/crates/fabro-server/src/server/handler/pair.rsor a focused sibling module if the handler becomes too large. - Add detail helpers in the existing run event handler module.
- Use existing run store event listing APIs; do not add new store schema.
Steps:
- Reconstruct pair windows from
run.pair.started,run.pair.ended, andrun.pair.failed. - Build compact transcript entries from pair events and matching agent events inside the pair window.
- Exclude delta events and full tool output.
- Build deterministic compact tool summaries with
detail_ref.seq. - Compute
next_since_seqas highest scanned source event sequence plus1. - Implement run event detail lookup by sequence only.
- Split run event detail responses into metadata, non-content properties, and truncated/redacted content.
- Apply
max_content_lengthtruncation consistently and reporttruncatedandredacted.
Test Plan
Run tests test-first for each implementation unit.
Required focused tests:
fabro-api: OpenAPI generation, shared type identity, JSON parity for selectors, pair records/messages/transcript/event detail.fabro-workflow: event names, event conversion, serialized event shapes, envelope actor/session/stage fields, single-target synchronous pair lifecycle, and message rejection when target cannot accept.fabro-agent: pair start parks the selected target only, pair message resumes the selected target, no-tool completion remains paired, pair end resumes/release, steering behavior unchanged.fabro-interviewand CLI runner: worker control protocol round trips forpair.start,pair.message, andpair.end, including runtime rejection results.fabro-server: every endpoint success shape, every documented409code,404pair/run/event not found,503worker unavailable, stalepair_id, exact target selection, no broadcast pairing when multiple targets are active,POST /pairreturns200 activeonly after runtime confirmation,DELETE /pairreturns200 endedonly after runtime confirmation, transcript projection, cursor advancement over excluded events, event detail truncation/redaction, and run event persistence.
Required commands:
cargo build -p fabro-api
cargo nextest run -p fabro-agent -p fabro-workflow -p fabro-server pair
cargo nextest run -p fabro-interview
cargo nextest run -p fabro-server steer interrupt
cargo +nightly-2026-04-14 fmt --check --all
cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings
If cargo nextest run fails with Too many open files, rerun with:
ulimit -n 4096 && cargo nextest run -p fabro-agent -p fabro-workflow -p fabro-server pair
Assumptions
- V1 pairing is single-target.
POST /pairrequires a target selector and never broadcasts to all active pair-capable targets. POST /pairandDELETE /pair/{pair_id}synchronously confirm lifecycle changes at the runtime boundary and return200, not202.client_message_idis correlation-only in v1, not an idempotency guarantee.- Pair transcript is a server read-side projection over
RunEvents. - Full details use the generic run-event detail endpoint, not a pair-specific endpoint.
- Existing steering APIs and event names remain backward-compatible.
- No MCP, frontend, or
/sessionsremoval happens in this slice.