Repository navigation
feat(agent-tools): queue a FAP send behind the running turn (delivery auto, follow_up) - #5090
code-yeongyu wants to merge 2 commits into
Conversation
… auto, follow_up) A thread_send while the child's turn runs (or while it waits on a person's card) no longer answers busy: it waits behind the turn as its own turn (<child id>.q<n>), at most eight per child, and goes when the turn ends, oldest first, through the same checks a send has. Its receipt, thread_read, events and result file keep naming it by its queued id. Ovis's earlier calls without delivery still answer busy.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
… and all but session before the ack
|
@devswha one more alignment, pushed as In Ovis, only a spec-attached FAP agent whose spec says |
|
Hi @code-yeongyu, a quick note: this PR wasn't closed by us. Its base branch |
…AP models, fork a Claude Code child (FAP) (#5101) Two small FAP agent-tools changes by @code-yeongyu, bundled into one pull request (same area, one CI run): **Part 1** queues a send behind the running turn (#5090), **Part 2** answers `models` from the running agent and forks a Claude Code child's session (#5097, earlier opened as #5102). Each part keeps his commits and authorship, with one maintainer commit from its review round. # Part 1: queue a FAP send behind the running turn ## What @code-yeongyu's #5090, rebased on main. GitHub closed it when its base `release/fap-align` was deleted at #5075's merge, so it lands from here; his two commits keep his authorship. Thank you, @code-yeongyu. - A `thread_send` while the child's turn runs (or while it waits on a person's card), with `delivery` `auto` (default) or `follow_up`, waits behind that turn as its own turn and goes when the turn ends, oldest first. The receipt says `delivery: follow_up` and names the turn `<child id>.q<n>`, which `thread_read` (`status: queued`), `events` and the receipt's `result_path` keep naming after it runs. - At most 8 queued per child (`ovis_code: queue_full`); closing the child drops them; a repeated `idempotency_key` answers the first. - Each queued message goes through the checks a send has, read again when it goes (held or taken over, a revoked grant, Lead agents off); one that can no longer go ends as an `error` turn and is never sent twice. - The queue is kept on the child's ledger row (`queue`, `queue_seq`), so it survives a restart; a reader from before ignores those fields. - Ovis's earlier fap/1 callers that send no `delivery` keep getting `busy`. - An attached FAP agent's frame naming another turn (`turn_id`) is dropped, and before its ack only `session` is read, so a late `turn_ended` never ends the queued turn after it. On the design note in #5090 (docs/harness-contract.md "no queue"): the owner approved this direction. The queue keeps only the caller's own messages, in its order, unchanged; Ovis decides nothing about what to send. ## Review round (omo gate + Codex via the team proxy, gpt-6.2-sol-fast xhigh) Supply chain: no dependency, lockfile, workflow or script change, no network call. Codex's first run was stopped by the provider's content filter; it was re-run with plain correctness wording. Fixed in the maintainer commit: - HIGH: a queued message could go after its sender lost its grant (a lowered depth, tools turned off and on). It now goes only while the run that sent it still owns the child and may still send; otherwise it ends as refused. - HIGH: another PC's run could leave a message queued here that later went without its own PC's grant check. Such calls are never queued: they answer `busy`. - HIGH: a restart while a queued send was under way could send it again. The send is marked before it goes; after a restart a marked one is refused, never sent twice. - A wake during a queued send is kept; the queue is looked at on startup, on settings changes and on a person's takeover. - A refused queued message stays readable as an `error` turn under its queued id, and a watch on it ends. - A sent queued turn's end is also told under its queued id (also when the turn ended before its send answered), and `thread_read` by the queued id keeps that id, with the sent one in `ovis.sent_as`. - A key that already named a sent turn is a retry for the driver, not a new queued message. - An agent's rejected prompt answers `bad_request`, not `busy`, so it never queues; `queue_full` joins `RefusalCode`. - Tests for each of these (grant lost, other PC, restart with a send under way, a busy terminal child, a legacy send while one waits). Not changed here: an ACP child's earlier answer stops being readable once its next turn starts. That is already so for any second send today (not only queued ones); it is a follow-up for the ACP turn store. ## Checks typecheck green, generated types fresh, `bun test server/agent-tools` 220 pass, 0 fail (+ cross-pc 26/26). # Part 2: FAP models and fork_from ## What @code-yeongyu's #5097, rebased on main. GitHub closed it when its base `release/fap-align` was deleted at #5075's merge, so it lands from here; his commit keeps his authorship. Thank you, @code-yeongyu. - **`models({ harness })`** answers with the models the caller's running child of that harness offers (the same controls as `thread_set_model`; `default` = its current model, `ovis.from_thread` names the child). While the caller runs none it answers `unsupported`, `reason: models_unlisted`, the spec's refusal for a harness that cannot list models. - **`thread_create({ fork_from })`** names one of the caller's own threads of the same harness on this PC whose agent already told its session; the new child opens in a terminal on a copy of that session where the agent's launch forks one. New optional `launch.fork_args` in the agent descriptions (`{session}` placeholder); only Claude Code sets it (`--resume {session} --fork-session`). The session id is checked against a strict pattern before it goes on the command line; a Codex child on its own app server refuses instead of dropping the fork. `capabilities.fork` reports it per harness. - `json_schema` stays unoffered (it needs a validator); `harnesses` keeps not listing `structured_output`. ## Review round (omo gate + Codex via the team proxy, gpt-6.2-sol-fast xhigh) Supply chain: no dependency, lockfile, workflow or script change, no network call. The session id goes onto argv only after a strict pattern, as a separate argument. Real agent: Claude Code 2.1.330 in an isolated HOME (team proxy, claude-haiku-4-5): `--resume <id> --fork-session` continued the conversation (it recalled the word it was given) under a new session id, also when run from a different folder. Fixed in the maintainer commit: - `fork_from` with another PC is refused before any card (it opened an unforked child). - A fork's source must be a live terminal child of this PC that no person holds: not an ACP or app-server child, not one a person took over. - `models` tries the caller's children of that harness newest first until one offers models, and a read that a takeover or a lost grant overtook answers that instead of the list. ## Checks typecheck green, `bun test` of server/agent-tools, server/approvals, conventions and changelog: 486 pass, 0 fail. ## Combined checks On the bundled branch: typecheck green, generated types fresh, `bun test` of server/agent-tools, server/approvals, conventions, changelog, plugin-agent and agent-descriptions: 499 pass, 0 fail. Supersedes #5090 and #5097 (and #5102). --------- Co-authored-by: YeonGyu-Kim <[email protected]>
What
A
thread_sendto a child whose turn is running (or that waits on a person's card) no longer answersunsupported/ovis_code: busy. Withdelivery: auto(the default) orfollow_up, the message waits behind the running turn as its own turn and is sent when that turn ends, oldest first.delivery: follow_upwith a stable turn id<child id>.q<n>.thread_read(status: queueduntil it goes,thread.queuedcount), theeventswatch and the receipt'sresult_pathkeep naming the turn by that id after it runs (the result file carriesovis.sent_as).ovis_code: queue_full). Closing the child drops them. A repeat with the sameidempotency_keyanswers the first.errorturn and is never sent twice. An unconfirmed delivery is not retried.queue,queue_seq), so it survives a restart.deliverykeep gettingbusyfor the deprecation release.Why
The FAP spec by Sisyphus Labs defines
thread_send'sdeliveryasauto(default),follow_uporsteer, and the reference host queuesautoandfollow_upbehind a running turn; onlysteersteers. A caller that sends twice in a row (the common orchestration shape) got a hard refusal from Ovis. The spec now also states this explicitly for second hosts ("What a host must offer").Design note for you, @devswha
docs/harness-contract.mdlists "no queue" among the things that would make Ovis an orchestrator (plan 12.2). I edited that paragraph to separate the two: this queue only keeps the caller's own messages in the caller's order and sends them unchanged. Ovis decides nothing about what to send, retries nothing and fans nothing out. If you'd rather keep that line as it was, this PR is the place to say no, and I'll close it.Tests
Run on a Linux x86_64 box (bun 1.4.5) at head
be655c60:bun run typecheck: okbun run check fast: workflow syntax, generated types, generated themes, typecheck and build ok. Unit: 27944 pass, 1 fail, 403 skip. The one failure isserver/account/pc-binding.test.ts("a stale lock another server took over first is not removed again"), which fails the same way at the feat(agent-tools): follow the Sisyphus Labs FAP spec (thread_* calls, envelope, receipts, FAP agent wire) #5075 head2c34e380, so it was already failing and this PR doesn't touch it.bun test server/agent-tools/: all queue tests pass.access.contract.test.tsandlaunch.test.tsfail the same way at2c34e380on that box, also not from this PR.New:
fap-face.test.ts"queues sends behind a running turn, steers it meanwhile, and runs the queued ones in order once it ends" (receipts, idempotency,queuedread, a steer while queued, interrupt then FIFO run, result file under the queued id, order of the sent turns).New: "holds at most eight queued messages, and drops them with the thread".
The earlier test that pinned the
busyrefusal was rewritten, since that behaviour is what this PR changes.A race found by the parallel unit run is fixed: a queued turn that ended before its own send answered left the next message unsent. The pump now looks again after any progress.
This stacks on #5075. Happy to rebase or reshape it however you prefer.
Update: late agent frames (head
b2228b6d)A queued turn starts right after the previous one ends, so a late frame from an attached FAP agent could end or fill it. Aligned with the reference host's fix (sisyphuslabs/omo-harness-skill#140; the spec text follows there): agent frames may carry an optional
turn_id, a frame naming another turn is dropped, and before the prompt's ack only thesessionframe is read. New test indrivers/fap-conversation.test.ts(an earlyturn_ended, a staleturn_endedand a staleassistanttaggedt0001don't toucht0002).bun run typecheckok, andbun test server/agent-tools/gives 215 pass, 2 fail (the two that also fail at2c34e380).The link
helloversions / error code 3 change on the host side (sisyphuslabs/omo-harness-skill#142) has no counterpart here: Ovis's FAP face has no link route.