Skip to content

feat(agent-tools): answer FAP models from the running agent, and fork a Claude Code child's session - #5097

Closed
code-yeongyu wants to merge 1 commit into
devswha:release/fap-alignfrom
code-yeongyu:fap/models-fork
Closed

code-yeongyu wants to merge 1 commit into
devswha:release/fap-alignfrom
code-yeongyu:fap/models-fork

Conversation

@code-yeongyu

Copy link
Copy Markdown
Contributor

What

Two FAP parts that Ovis listed as "not offered":

  • models({ harness }). Ovis already learns a harness's models from a running agent (the same ModelControl the composer's model switch and thread_set_model use). It never keeps a list of its own, so models answers with what the caller's running child of that harness offers (default = its current model, ovis.from_thread names the child). While the caller runs none, it answers unsupported with reason: models_unlisted, which is exactly the refusal the spec defines for a harness that can't list models.
  • thread_create({ fork_from }). It 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 can fork one. New optional launch.fork_args in the agent descriptions (schema + regenerated types) uses a {session} placeholder. Today only Claude Code sets it: --resume {session} --fork-session. The session id is checked against a strict pattern before it goes on argv, and a Codex child on its own app server refuses instead of silently dropping the fork. capabilities.fork now reports this per harness instead of a constant false.
  • docs/fap.md "Not offered" is updated. install stays out: the spec now says it installs the reference host itself and isn't a FAP call.

Not in this PR

json_schema stays unoffered. Doing it properly needs a JSON Schema validator for the prompted form (the spec's host now validates the last JSON block against the schema), and Ovis has none in its dependencies. That's your call: add a validator dependency, or have me write a small one for the subset the spec needs. Until then harnesses doesn't list structured_output, which per the spec means "can't take a schema".

Why

The FAP spec by Sisyphus Labs makes models, fork_from and json_schema capability-gated, each with a defined refusal. Ovis now offers the two it can honour with what it already has, and reports the third truthfully.

Tests

bun run check fast at 7786c305 on a Linux x86_64 box (bun 1.4.5): workflow syntax, generated types (fresh), themes, typecheck and build ok. Unit: 27945 pass, 2 fail. One failure was mine: the MCP tool list in hub.test.ts didn't include models, and that's fixed. The other, server/account/pc-binding.test.ts, fails the same way at the #5075 head 2c34e380. At the final head 3f380837: bun run typecheck ok, and bun test server/agent-tools/ gives 216 pass, 2 fail. Those two (access.contract.test.ts, launch.test.ts) fail the same way at 2c34e380 on that box.

  • New fap-face.test.ts cases: models from the running child, models_unlisted without one, and an empty list. fork_from refuses another run's thread (not_found) and a harness whose launch can't fork (unsupported), and nothing is typed.
  • New drivers/terminal.test.ts case: Claude's argv ends --resume <id> --fork-session, a flag-shaped session id is refused, and a harness with no fork_args is refused, with one launch total.
  • scope and the MCP tool list now include models.

@devswha this stacks on #5075. Happy to rebase or reshape it however you prefer.

… a Claude Code child's session (fork_from)

models lists what the caller's running child of a harness offers, else unsupported with reason models_unlisted. thread_create fork_from opens a terminal child on a copy of the caller's own child's session where the agent's launch forks one (Claude Code --resume <session> --fork-session); capabilities.fork says so per harness.
@coderabbitai

coderabbitai Bot commented Nov 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@devswha

devswha commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Hi @code-yeongyu, a quick note: this PR wasn't closed by us. Its base branch release/fap-align was deleted when #5075 merged, and GitHub closes a PR when its base goes. Your commits carry on, with your authorship, rebased on main in #5102, together with the fixes from the review round. Thank you for this work!

@devswha

devswha commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Small update, @code-yeongyu: under our bundle-by-area rule, #5102 is now folded into #5101 together with your queue change, so this work lands there with your authorship.

devswha added a commit that referenced this pull request Nov 30, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants