feat(presets): what runs apart from where — a child runs like its parent, Runs on beats a preset's machine #65

Closed
gabrielvidal wants to merge 0 commits from preset-machine-split into main
pull from: preset-machine-split
Owner

Summary

An agent preset is now what runs (harness, model, effort, thinking). Where it runs is a separate pick: a preset's machine is only a default, which the run's own machine pick beats. A conversation started from another one — ai-agent new inside a run, --detach included, or hub-mcp start_conversation like= — now runs like it by default: it takes the parent's preset (else its exact harness/model/effort/thinking) and the parent's machine, for whatever the caller left unset. Gabriel's choices are in form presets-vs-machines_uwgxdv.

Goes with ai-agent-plugins #63 (agent-presets 1.1.0, hub-mcp 1.3.0): merge the two together.

Key changes

  • backend/runs/inherit.py (new): /api/spawn with parent (or the new like) fills the unset settings from that conversation.
    • Model settings (no model, no harness): the parent's preset, re-routed. Otherwise its harness, model (route.exact → transcript contextModel → meta.model), effort, thinking and additional system prompt. Its login comes too when the machine is also inherited.
    • Machine (no worker): the parent's machine (the lab for a lab run), plus its profile. A lab-only harness (pi) ignores it.
    • The runs.route provider's child default may name a preset instead. "Same as parent" (parent) or no default means inherit.
    • The inherited machine is soft. A spawn that fails on it (worker_offline, preset_unroutable, worker_harness, account) is retried without it, and the answer carries inherited.machineDropped.
    • The spawn answers inherited (SpawnInherited schema). A guest's conversation passes nothing on.
  • runs/routes.py: SpawnBody.like, plus the soft retry. A worker CLI's like must be visible to it, like parent.
  • runs/service.py:
    • A route's thinking applies when the caller sent none, both on a new run and on a step-down (popped from the meta patch).
    • meta.model is stamped at spawn and resume, so a child started before its parent's transcript is indexed still gets the model.
  • plugins/run_router.py:
    • brief(…, worker) and GET /api/plugins/run-presets?worker= (resolved through workers/picks, so names and lab work), cached per machine.
    • resolve and turn pass thinking through.
  • CLI (cli/ai_agent.py):
    • --preset NAME, the same as --model preset:NAME. Combining it with --model or --harness is refused.
    • --detach inside a run sends like (no link and no report-back, but the same defaults).
    • What was inherited is printed on stderr, or included in the JSON with --json.
    • The docstring explains the two picks and repeats the rule never to drop --model to get past an error.
  • Composer:
    • AgentPresetPicker loses its Machine section and the Custom chip's machine suffix. Save as preset also saves the thinking setting.
    • SpawnComposer shows the Runs on chip (WorkerSelect) next to the preset chip. In preset mode the pick is sent as worker together with preset:<id>, and the brief is fetched per pick.
    • WorkerSelect gains autoHint ("Best's default machine — EVOX2").
    • A preset row's default-machine badge is struck through when the Runs on pick overrides it.
  • schemas/misc.py (LadderNow fields, RunPresetsResponse.worker, SpawnInherited), plus openapi.json and src/generated regenerated, and core/i18n_keys/ui.json updated (3 new strings, 1 stale one dropped).
  • Mock: the mock agent-presets plugin honours ?worker=, Best has a default machine, and child is parent.
  • Docs: the agent-presets section of CLAUDE.md and the run-presets endpoint in docs/plugins.md.

Key decisions

  • Preset machines stay, as defaults (Gabriel: "Keep as default the machine pick overrides"). The precedence is: explicit pick (Runs on / --on) > the parent's machine > the route's machine > the preset's machine > the profile's default.
  • Inheritance happens on the hub, not in the CLI. The CLI, hub-mcp and worker CLIs (through the outbox) all get it, and the hub can read the parent's meta and transcript, which the CLI can't.
  • Each pick is independent: --model keeps the parent's machine, --on keeps its model settings. The parent's login only follows when the machine does too, since another machine may not hold it.
  • The inherited machine is soft: it never turns a spawn that would have worked into a 409. The fallback is said, not silent.
  • A parent on a preset passes the preset on, even when the parent is on an exact pick or a stepped-down route, so the child gets the ladder rather than one model (form: "Its preset, else harness/model/effort/thinking").
  • like rather than reusing parent with report:false: a detached run stays out of the parent's children list and its fan-out limit.

Changelog

  • Added: a conversation started from another one (ai-agent new inside a run, --detach too) runs like it by default — same agent preset (or model, effort and thinking) and same machine; it says so on stderr.
  • Added: ai-agent new --preset NAME.
  • Added: hub-mcp start_conversation like= to start a conversation that runs like another one.
  • Changed: the composer's agent-preset chip is only the model settings; the machine is its own Runs on chip, and picking one beats the preset's default machine.
  • Added: agent preset routes can turn thinking on or off.
  • Fixed: a follow-up that picks a preset (ai-agent send --model preset:best) no longer fails, and presets step down to the next route in place again.

Test notes

  • Backend (EVOX2, each module in its own bwrap sandbox with a throwaway /data): 190 modules. 184 pass. The 6 that fail (test_agy, test_authz_matrix, test_local_energy, test_opencode, test_profiles, test_typed_plugins) fail on main with the same test ids (full lists diffed).
    • New: test_spawn_inherit.py (20 tests: preset and exact parents, explicit picks, lab-only harness, guest parent, the soft-machine retry, like without the child link).
    • test_run_router.py: thinking on resolve and step-down, the brief per machine, ?worker=lab and an unknown worker.
  • CLI: 7 modules pass (test_ai_agent 73, including --preset, like on --detach, and the inherited line).
  • Frontend: tsc --noEmit is clean, and vitest passes 189 files / 1,240 tests (SpawnPreset.test.tsx adds a Runs on pick going out with the preset and the brief asked with worker=).
  • Live: a local hub on this branch seeded with the plugins branch, plus a fake sidecar that records the launches. The real CLI:
    • new in a Best conversation → "like this conversation — the Best preset on the Homelab", launched on Fable.
    • --model sonnet → only the machine.
    • --detach → like.
    • A child of a sonnet --effort high --no-think parent → sonnet · high · thinking false · its login, which proves the meta.model stamp.
    • --preset free → pi.
    • POST /api/resume with preset:everyday → 200 (a 409 on main's plugin).
    • Setting "Thinking off" in the settings page → the next Best spawn launched with thinking: false.
  • Screenshots: the composer on the mock build (two chips; Runs on with auto: Best's default machine; the Best default machine struck through after picking Homelab; the Custom tab without a machine).
  • Not deployed from the EVOX2: merge together with the plugins PR, then deploy the hub and reload agent-presets, hub-mcp and translation-fr from the Homelab.
  • Related: conversation cb8d4ecc (CLI spawn machine/model forensics) proposes "pi on workers" and clearer errors. This PR covers its "child inherits the parent's model" item. Left alone, as asked.

🤖 Generated with Claude Code

Screenshots

01-composer-two-chips.png
02-runs-on-popover.png
03-preset-popover-machine-picked.png
04-custom-tab-no-machine.png

## Summary An agent preset is now *what* runs (harness, model, effort, thinking). *Where* it runs is a separate pick: a preset's machine is only a default, which the run's own machine pick beats. A conversation started from another one — `ai-agent new` inside a run, `--detach` included, or hub-mcp `start_conversation like=` — now **runs like it** by default: it takes the parent's preset (else its exact harness/model/effort/thinking) and the parent's machine, for whatever the caller left unset. Gabriel's choices are in form `presets-vs-machines_uwgxdv`. Goes with **ai-agent-plugins #63** (agent-presets 1.1.0, hub-mcp 1.3.0): merge the two together. ## Key changes - **`backend/runs/inherit.py`** (new): `/api/spawn` with `parent` (or the new `like`) fills the unset settings from that conversation. - **Model settings** (no `model`, no `harness`): the parent's preset, re-routed. Otherwise its harness, model (`route.exact` → transcript `contextModel` → `meta.model`), effort, thinking and additional system prompt. Its login comes too when the machine is also inherited. - **Machine** (no `worker`): the parent's machine (the lab for a lab run), plus its profile. A lab-only harness (pi) ignores it. - The runs.route provider's `child` default may name a preset instead. "Same as parent" (`parent`) or no default means inherit. - The inherited machine is *soft*. A spawn that fails on it (`worker_offline`, `preset_unroutable`, `worker_harness`, `account`) is retried without it, and the answer carries `inherited.machineDropped`. - The spawn answers `inherited` (`SpawnInherited` schema). A guest's conversation passes nothing on. - **`runs/routes.py`**: `SpawnBody.like`, plus the soft retry. A worker CLI's `like` must be visible to it, like `parent`. - **`runs/service.py`**: - A route's `thinking` applies when the caller sent none, both on a new run and on a step-down (popped from the meta patch). - `meta.model` is stamped at spawn and resume, so a child started before its parent's transcript is indexed still gets the model. - **`plugins/run_router.py`**: - `brief(…, worker)` and `GET /api/plugins/run-presets?worker=` (resolved through `workers/picks`, so names and `lab` work), cached per machine. - `resolve` and `turn` pass `thinking` through. - **CLI (`cli/ai_agent.py`)**: - `--preset NAME`, the same as `--model preset:NAME`. Combining it with `--model` or `--harness` is refused. - `--detach` inside a run sends `like` (no link and no report-back, but the same defaults). - What was inherited is printed on stderr, or included in the JSON with `--json`. - The docstring explains the two picks and repeats the rule never to drop `--model` to get past an error. - **Composer**: - `AgentPresetPicker` loses its Machine section and the Custom chip's machine suffix. *Save as preset* also saves the thinking setting. - `SpawnComposer` shows the **Runs on** chip (`WorkerSelect`) next to the preset chip. In preset mode the pick is sent as `worker` together with `preset:<id>`, and the brief is fetched per pick. - `WorkerSelect` gains `autoHint` ("Best's default machine — EVOX2"). - A preset row's default-machine badge is struck through when the Runs on pick overrides it. - `schemas/misc.py` (`LadderNow` fields, `RunPresetsResponse.worker`, `SpawnInherited`), plus `openapi.json` and `src/generated` regenerated, and `core/i18n_keys/ui.json` updated (3 new strings, 1 stale one dropped). - Mock: the mock agent-presets plugin honours `?worker=`, Best has a default machine, and `child` is `parent`. - Docs: the agent-presets section of `CLAUDE.md` and the run-presets endpoint in `docs/plugins.md`. ## Key decisions - **Preset machines stay, as defaults** (Gabriel: "Keep as default the machine pick overrides"). The precedence is: explicit pick (Runs on / `--on`) > the parent's machine > the route's machine > the preset's machine > the profile's default. - **Inheritance happens on the hub, not in the CLI.** The CLI, hub-mcp and worker CLIs (through the outbox) all get it, and the hub can read the parent's meta and transcript, which the CLI can't. - **Each pick is independent:** `--model` keeps the parent's machine, `--on` keeps its model settings. The parent's login only follows when the machine does too, since another machine may not hold it. - **The inherited machine is soft:** it never turns a spawn that would have worked into a 409. The fallback is said, not silent. - **A parent on a preset passes the preset on**, even when the parent is on an exact pick or a stepped-down route, so the child gets the ladder rather than one model (form: "Its preset, else harness/model/effort/thinking"). - `like` rather than reusing `parent` with `report:false`: a detached run stays out of the parent's children list and its fan-out limit. ## Changelog - Added: a conversation started from another one (`ai-agent new` inside a run, `--detach` too) runs like it by default — same agent preset (or model, effort and thinking) and same machine; it says so on stderr. - Added: `ai-agent new --preset NAME`. - Added: hub-mcp `start_conversation like=` to start a conversation that runs like another one. - Changed: the composer's agent-preset chip is only the model settings; the machine is its own Runs on chip, and picking one beats the preset's default machine. - Added: agent preset routes can turn thinking on or off. - Fixed: a follow-up that picks a preset (`ai-agent send --model preset:best`) no longer fails, and presets step down to the next route in place again. ## Test notes - Backend (EVOX2, each module in its own bwrap sandbox with a throwaway `/data`): 190 modules. 184 pass. The 6 that fail (`test_agy`, `test_authz_matrix`, `test_local_energy`, `test_opencode`, `test_profiles`, `test_typed_plugins`) fail on main with the **same** test ids (full lists diffed). - New: `test_spawn_inherit.py` (20 tests: preset and exact parents, explicit picks, lab-only harness, guest parent, the soft-machine retry, `like` without the child link). - `test_run_router.py`: thinking on resolve and step-down, the brief per machine, `?worker=lab` and an unknown worker. - CLI: 7 modules pass (`test_ai_agent` 73, including `--preset`, `like` on `--detach`, and the inherited line). - Frontend: `tsc --noEmit` is clean, and vitest passes 189 files / 1,240 tests (`SpawnPreset.test.tsx` adds a Runs on pick going out with the preset and the brief asked with `worker=`). - **Live:** a local hub on this branch seeded with the plugins branch, plus a fake sidecar that records the launches. The real CLI: - `new` in a Best conversation → "like this conversation — the Best preset on the Homelab", launched on Fable. - `--model sonnet` → only the machine. - `--detach` → `like`. - A child of a `sonnet --effort high --no-think` parent → sonnet · high · thinking false · its login, which proves the `meta.model` stamp. - `--preset free` → pi. - `POST /api/resume` with `preset:everyday` → 200 (a 409 on main's plugin). - Setting "Thinking off" in the settings page → the next Best spawn launched with `thinking: false`. - Screenshots: the composer on the mock build (two chips; Runs on with *auto: Best's default machine*; the Best default machine struck through after picking Homelab; the Custom tab without a machine). - **Not deployed from the EVOX2:** merge together with the plugins PR, then deploy the hub and reload agent-presets, hub-mcp and translation-fr from the Homelab. - Related: conversation `cb8d4ecc` (CLI spawn machine/model forensics) proposes "pi on workers" and clearer errors. This PR covers its "child inherits the parent's model" item. Left alone, as asked. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ## Screenshots ![01-composer-two-chips.png](https://git.gabvdl.xyz/attachments/46d24d44-3b6d-467b-8404-84754addcedf) ![02-runs-on-popover.png](https://git.gabvdl.xyz/attachments/5a608831-79fd-47dd-ad19-426ed1506f95) ![03-preset-popover-machine-picked.png](https://git.gabvdl.xyz/attachments/49303fdc-fde2-49de-b4c1-b47d40873be7) ![04-custom-tab-no-machine.png](https://git.gabvdl.xyz/attachments/a79ee128-a1fd-43b2-bc07-dd175ed9dc3a)
gabrielvidal self-assigned this 2026-12-02 23:12:18 +01:00
gabrielvidal added 1 commit 2026-12-02 23:12:18 +01:00
- runs/inherit.py: /api/spawn with parent (or the new like, for --detach and
  hub-mcp start_conversation like=) fills what the caller left unset from that
  conversation: its agent preset, else its harness/model/effort/thinking (+ its
  login with its machine), and its machine. The inherited machine is soft: a
  spawn failing on it (offline, no route there, no login) is retried without.
  The spawn answers inherited; the CLI prints it. The child default of the
  runs.route provider may name a preset instead (Same as parent = parent).
- ai-agent new --preset NAME (= --model preset:NAME); --detach sends like.
- Composer: the preset/model chip loses Machine; a separate Runs on chip
  beats the preset's default machine; the brief is evaluated per machine pick
  (GET /api/plugins/run-presets?worker=), a row's default machine is struck
  through when overridden.
- Thinking per route: resolve/turn answer thinking, applied when the caller
  sent none (step-downs too).
- meta.model stamped at spawn/resume (a child started before its parent's
  transcript is indexed still gets its model).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner
Merged into `main` as f1c864c8 by the auto-ship batch https://ai-agent.lab.gabvdl.xyz/conversation/9527ab6e-d304-4ef3-b27b-061eb0f2ccf0.
gabrielvidal closed this pull request 2026-12-02 23:38:02 +01:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gabrielvidal/ai-agent#65