feat(runs): pi runs on the owner's workers; a refused run says where it can go #66

Closed
gabrielvidal wants to merge 0 commits from pi-on-workers into main
pull from: pi-on-workers
Owner

Summary

pi runs can now live on one of the owner's workers, and a refused run says where it can go. Conversation 01a23883 was a pi/Qwen 3.8 Abliterated run told to spawn its next step on the Mac. It ran ai-agent new --on <worker> --model qwen3.8-27b-abliterated and got "pi runs on the Homelab only". It then dropped --model to get past the error, and three Opus 5.5 children ran (two on the EVOX2, one on the Mac). #65 already fixed the "no model → Opus" half: a child now runs like its parent. This PR fixes the other half. pi can run on a worker that's asked for, and refusals name a way out instead of leaving the caller to drop its pick.

Key changes

  • Routing (runs/service.py route_new_run):
    • A harness that isn't a login (pi) runs on a worker only when one is asked for: --on / Runs on, or the machine a child inherits. An unpinned pi run still goes to the lab (_no_login).
    • The worker must say it can (runReady).
    • Refusals carry a hint (_hint): the other machines that run this harness on the model's vendor, and the other harnesses that run it on the machine asked for.
    • A worker without pi gets " can't run pi runs yet — install pi from its Setup page" instead of "has no pi login".
  • Which workers hold pi (profiles/store.worker_logins_by_harness): a worker whose /health says runReady: {pi: true} holds pi's keyless accounts (EVOX2, Colab). Never a guest's computer, never OpenRouter. workers/store persists runReady from /health.
  • The lab's servers ride along (runs/service.harness_extras, in _launch and the fork): for a pi run on an owner worker, the hub asks the host sidecar's new GET /harnesses/{id}/worker-extras (the driver's worker_extras()). It passes the answer as the run body's harnessExtras (new on the sidecar's Spawn/Resume/Fork bodies).
  • Sidecar driver contract (harness_base): two optional hooks, run_ready() (→ the worker's /health runReady map) and worker_extras() (host only).
  • Transcripts (sidecar.py feed roots, config.PI_RUNNER_TRANSCRIPTS, workers/remotefeed.py, core/state.py): a worker's /feed lists the pi runner's mirror as @pi/local/<slug>/<sid>.jsonl. The hub lands it in the usual layout and stamps workerSource only, since the spawn already stamped the account. Resume and fork then follow the session to that worker.
  • CLI (cli/ai_agent.py, the ai-agent skill): refusals print their hint. A refused new / send / fork that named --model / --on / --harness adds "Don't retry without --model / --on / --harness to get past this: pick what the hint names, or stop and say so." The help text and the guest skill say the same.
  • The backend fixture of harness-pi is now runsOn: "any". The worker Setup row and the Logins hint no longer say pi runs stay on the lab (i18n key list regenerated). CLAUDE.md gets a "pi runs on a worker" section.

Key decisions

  • An unpinned pi run stays on the lab. Routing pi by profile would have changed every composer pi run. Personal's default machine is the EVOX2, which would start taking them and refuse them when pi isn't ready there. Workers are opt-in per run (pinned or inherited), and inherit.py's soft machine already falls back to the lab when the worker refuses (worker_harness).
  • runReady instead of a login. pi has no login, so "can this machine run it" is the driver's call: its pi, or node + npm to install it.
  • Extras through the host's driver, not a manifest flag. A new manifest key would make an older hub reject harness-pi 1.3.0. The hub only asks for harnesses that aren't a login (pi), so opencode/agy worker runs don't pay a host round trip. An older host sidecar (404) just means no extras.
  • The key goes to the owner's workers only. The alternative was a hub-side proxy for local model calls, like the opencode proxy. It was rejected because every Mac→EVOX2 token would stream through the lab.
  • The hint is data, the "don't drop it" rule is the CLI's. The composer shows the hint too, where "don't retry without --model" would read oddly.

Changelog

  • Added: pi runs on your own workers — pin a machine (--on, Runs on) with an EVOX2 or Colab model and pi runs there.
  • Changed: when the hub refuses to start a run, the message says which machines or harnesses can run it instead.
  • Changed: the ai-agent CLI tells agents not to drop --model / --on / --harness to get past a refusal.

Test notes

  • New backend tests: backend/test_pi_on_workers.py, 8 passed (bwrap + throwaway /data, pinned to the backend fixtures). They cover:
    • keyless accounts only, never on a guest's computer;
    • a pinned ready worker gets the spawn with harnessExtras and bills evox2;
    • unpinned pi still goes to the lab;
    • an unready worker says so and hints "the Homelab";
    • an OpenRouter model is refused on a worker;
    • a hint naming opencode on the same machine;
    • harness_extras scoping;
    • the @pi/local feed rel landing and stamping workerSource only.
  • New sidecar tests: sidecar/test_worker_extras.py, 6 passed: the route on host vs worker, harnessExtras reaching spawn, resume and fork, runReady per driver, and a broken driver never failing /health.
  • CLI: cli/test_ai_agent.py, 74 OK, including the hint and the retry warning.
  • Full suites compared to main (same environment):
    • sidecar: 6 failed / 729 passed, against 6 failed / 723 passed on main. The 6 failures are identical on both and come from this shell's env (ANTHROPIC_BASE_URL, …).
    • backend: every module, one bwrap each, branch vs main; 191 modules (190 on main), and the same 3 failures on both: test_authz_matrix ×2 (POST /api/ask/{id}/cancel has no authz entry, as the 2026-12-02 ship run found) and test_typed_plugins ×1. test_pi_on_workers 8 passed.
  • Frontend: tsc --noEmit clean; UPDATE_I18N_KEYS=1 npx vitest run src/i18n, then 7 passed.
  • A real pi turn off the lab (with ai-agent-plugins #64's driver, on the EVOX2, scratch HOME): servers merged into models.json (0600, OpenRouter's entry dropped), runner pi installed by npm ci, and inkling-2-mini answered OK through http://fedora:8091/v1. The transcript was mirrored under ~/.pi-runner/transcripts/, the new feed root.
  • No screenshots: no UI beyond two strings changed.
  • Merge and deploy: merge together with ai-agent-plugins #64 (harness-pi 1.3.0, which merges after plugins #57). Deploy the hub, then reload harness-pi, both from the Homelab; never from the EVOX2. Workers pick up the runReady / @pi sidecar code with their next update.

🤖 Generated with Claude Code

## Summary pi runs can now live on one of the owner's workers, and a refused run says where it *can* go. Conversation `01a23883` was a pi/Qwen 3.8 Abliterated run told to spawn its next step on the Mac. It ran `ai-agent new --on <worker> --model qwen3.8-27b-abliterated` and got "pi runs on the Homelab only". It then dropped `--model` to get past the error, and three Opus 5.5 children ran (two on the EVOX2, one on the Mac). #65 already fixed the "no model → Opus" half: a child now runs like its parent. This PR fixes the other half. pi can run on a worker that's asked for, and refusals name a way out instead of leaving the caller to drop its pick. ## Key changes - **Routing** (`runs/service.py` `route_new_run`): - A harness that isn't a login (pi) runs on a worker only when one is asked for: `--on` / Runs on, or the machine a child inherits. An unpinned pi run still goes to the lab (`_no_login`). - The worker must say it can (`runReady`). - Refusals carry a `hint` (`_hint`): the other machines that run this harness on the model's vendor, and the other harnesses that run it on the machine asked for. - A worker without pi gets "<machine> can't run pi runs yet — install pi from its Setup page" instead of "has no pi login". - **Which workers hold pi** (`profiles/store.worker_logins_by_harness`): a worker whose `/health` says `runReady: {pi: true}` holds pi's **keyless** accounts (EVOX2, Colab). Never a guest's computer, never OpenRouter. `workers/store` persists `runReady` from `/health`. - **The lab's servers ride along** (`runs/service.harness_extras`, in `_launch` and the fork): for a pi run on an owner worker, the hub asks the host sidecar's new `GET /harnesses/{id}/worker-extras` (the driver's `worker_extras()`). It passes the answer as the run body's `harnessExtras` (new on the sidecar's Spawn/Resume/Fork bodies). - **Sidecar driver contract** (`harness_base`): two optional hooks, `run_ready()` (→ the worker's `/health` `runReady` map) and `worker_extras()` (host only). - **Transcripts** (`sidecar.py` feed roots, `config.PI_RUNNER_TRANSCRIPTS`, `workers/remotefeed.py`, `core/state.py`): a worker's `/feed` lists the pi runner's mirror as `@pi/local/<slug>/<sid>.jsonl`. The hub lands it in the usual layout and stamps `workerSource` only, since the spawn already stamped the account. Resume and fork then follow the session to that worker. - **CLI** (`cli/ai_agent.py`, the ai-agent skill): refusals print their hint. A refused `new` / `send` / `fork` that named `--model` / `--on` / `--harness` adds "Don't retry without --model / --on / --harness to get past this: pick what the hint names, or stop and say so." The help text and the guest skill say the same. - The backend fixture of harness-pi is now `runsOn: "any"`. The worker Setup row and the Logins hint no longer say pi runs stay on the lab (i18n key list regenerated). CLAUDE.md gets a "pi runs on a worker" section. ## Key decisions - **An unpinned pi run stays on the lab.** Routing pi by profile would have changed every composer pi run. Personal's default machine is the EVOX2, which would start taking them and refuse them when pi isn't ready there. Workers are opt-in per run (pinned or inherited), and inherit.py's soft machine already falls back to the lab when the worker refuses (`worker_harness`). - **`runReady` instead of a login.** pi has no login, so "can this machine run it" is the driver's call: its pi, or node + npm to install it. - **Extras through the host's driver, not a manifest flag.** A new manifest key would make an older hub reject harness-pi 1.3.0. The hub only asks for harnesses that aren't a login (pi), so opencode/agy worker runs don't pay a host round trip. An older host sidecar (404) just means no extras. - **The key goes to the owner's workers only.** The alternative was a hub-side proxy for local model calls, like the opencode proxy. It was rejected because every Mac→EVOX2 token would stream through the lab. - **The hint is data, the "don't drop it" rule is the CLI's.** The composer shows the hint too, where "don't retry without --model" would read oddly. ## Changelog - Added: pi runs on your own workers — pin a machine (`--on`, Runs on) with an EVOX2 or Colab model and pi runs there. - Changed: when the hub refuses to start a run, the message says which machines or harnesses can run it instead. - Changed: the `ai-agent` CLI tells agents not to drop `--model` / `--on` / `--harness` to get past a refusal. ## Test notes - **New backend tests:** `backend/test_pi_on_workers.py`, 8 passed (bwrap + throwaway `/data`, pinned to the backend fixtures). They cover: - keyless accounts only, never on a guest's computer; - a pinned ready worker gets the spawn with `harnessExtras` and bills `evox2`; - unpinned pi still goes to the lab; - an unready worker says so and hints "the Homelab"; - an OpenRouter model is refused on a worker; - a hint naming opencode on the same machine; - `harness_extras` scoping; - the `@pi/local` feed rel landing and stamping `workerSource` only. - **New sidecar tests:** `sidecar/test_worker_extras.py`, 6 passed: the route on host vs worker, `harnessExtras` reaching spawn, resume and fork, `runReady` per driver, and a broken driver never failing `/health`. - **CLI:** `cli/test_ai_agent.py`, 74 OK, including the hint and the retry warning. - **Full suites compared to main** (same environment): - sidecar: 6 failed / 729 passed, against 6 failed / 723 passed on main. The 6 failures are identical on both and come from this shell's env (`ANTHROPIC_BASE_URL`, …). - backend: every module, one bwrap each, branch vs main; 191 modules (190 on main), and the same 3 failures on both: `test_authz_matrix` ×2 (`POST /api/ask/{id}/cancel` has no authz entry, as the 2026-12-02 ship run found) and `test_typed_plugins` ×1. `test_pi_on_workers` 8 passed. - Frontend: `tsc --noEmit` clean; `UPDATE_I18N_KEYS=1 npx vitest run src/i18n`, then 7 passed. - **A real pi turn off the lab** (with ai-agent-plugins #64's driver, on the EVOX2, scratch HOME): servers merged into models.json (0600, OpenRouter's entry dropped), runner pi installed by `npm ci`, and inkling-2-mini answered **OK** through `http://fedora:8091/v1`. The transcript was mirrored under `~/.pi-runner/transcripts/`, the new feed root. - **No screenshots:** no UI beyond two strings changed. - **Merge and deploy:** merge together with **ai-agent-plugins #64** (harness-pi 1.3.0, which merges after plugins #57). Deploy the hub, then reload harness-pi, both from the Homelab; never from the EVOX2. Workers pick up the `runReady` / `@pi` sidecar code with their next update. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
gabrielvidal self-assigned this 2026-12-03 00:25:14 +01:00
gabrielvidal added 1 commit 2026-12-03 00:25:14 +01:00
A pi/Qwen run told to spawn its next step on the Mac got "pi runs on the
Homelab only", dropped --model and started three Opus children (conv
01a23883, 2026-12-02). #65 made a child run like its parent; this lets pi run
on a worker that is asked for, and makes refusals name a way out.

- route_new_run: a harness that isn't a login (pi) goes to a worker only when
  one is pinned or inherited and says runReady — an unpinned pi run stays on
  the lab. Refusals carry a hint (_hint): the machines that run this harness
  on the model's vendor, the harnesses that run it on the machine asked for;
  a worker without pi says so (_not_here).
- profiles/store: a runReady worker holds pi's keyless accounts (EVOX2,
  Colab) — never a guest's computer, never OpenRouter; workers/store keeps
  runReady from /health.
- harness_extras: a pi run on an owner worker carries the host driver's
  worker_extras() (GET /harnesses/{id}/worker-extras — the lab's local
  servers) as harnessExtras, in _launch and the fork.
- sidecar: run_ready() / worker_extras() driver hooks, /health runReady,
  harnessExtras on the run bodies, the pi runner's mirror as the worker feed's
  @pi/local root; the hub lands it and stamps workerSource.
- CLI: refusals print their hint; a refused new/send/fork with --model / --on
  / --harness says not to retry without them. Help + ai-agent skill too.
- harness-pi fixture runsOn any; UI strings; i18n keys; CLAUDE.md section.
- tests: backend/test_pi_on_workers.py, sidecar/test_worker_extras.py, CLI.

Merge with ai-agent-plugins pi-on-workers (harness-pi 1.3.0).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner
Merged into `main` as 4002cb4e5980b35e66c39d5f2b14af83b97a8763 by the auto-ship batch https://ai-agent.lab.gabvdl.xyz/conversation/ef142e75-018b-4282-b8d6-b661f406bcec.
gabrielvidal closed this pull request 2026-12-03 00:54:54 +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#66