feat(runs): mid-run messages for any harness with the inbox cap (pi steering) #61

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

Summary

Mid-run messages were wired for Claude Code only: the backend sent them to a live run's inbox only when harness == "claude", and the sidecar's /message refused every other harness. Now the backend tries the inbox for any harness whose plugin declares the inbox cap, and the sidecar hands a non-Claude run's message to its harness driver. This PR is the core side of pi steering. Merge it together with ai-agent-plugins pi-steer (harness-pi 1.2.0).

Key changes

  • backend/runs/service.py: the inbox attempt is gated on _harness_has(harness, "inbox") instead of harness == "claude". harness-claude already declares the cap, so Claude behaves as before.
  • sidecar/harness_base.py: new optional message(sid, text, rec) hook. It returns {"delivered"}, {"refused"}, or NOT_HANDLED by default.
  • sidecar/routes_runs.py: /message for a non-Claude run calls that hook. A refusal, a missing hook or an exception gives 409 inbox_unavailable, and the backend falls back to the old force-resume.
  • The test fixture harness-pi declares inbox. New sidecar/test_message_harness.py.
  • Docs: CLAUDE.md and sidecar/README.md.

Key decisions

  • Gate on the manifest's existing inbox cap, not a hard-coded list. It was already in CAPS and declared by harness-claude.
  • Safe in any merge order: with this PR and the old harness-pi, pi has no cap, so behaviour is unchanged. With the new harness-pi and the old core, the backend still gates on Claude, so behaviour is also unchanged.

Changelog

  • Changed: a message sent mid-run reaches the running agent for every harness that supports it (Claude Code, and pi with harness-pi 1.2.0), not only Claude Code.

Test notes

  • Sidecar, full suite under uv: 689 passed, 6 failed. The same 6 fail on main (test_guard ×4, test_guest_accounts, test_harness_loader evox2).
  • Backend under bwrap: test_worker_routing (covers the Claude inbox path), test_children, test_run_isolation, test_worker_attachments, test_guest_computers, test_guests and test_plugin_hubruns all pass. test_typed_plugins: same result as main.
  • End to end with the real pi: see the ai-agent-plugins PR.
  • No UI change, so there are no screenshots. Deploy from the Homelab after merge (ai-agent deploy + sidecar restart). Nothing is deployed from the EVOX2.

🤖 Generated with Claude Code

## Summary Mid-run messages were wired for Claude Code only: the backend sent them to a live run's inbox only when `harness == "claude"`, and the sidecar's `/message` refused every other harness. Now the backend tries the inbox for any harness whose plugin declares the `inbox` cap, and the sidecar hands a non-Claude run's message to its harness driver. This PR is the core side of pi steering. Merge it together with ai-agent-plugins `pi-steer` (harness-pi 1.2.0). ## Key changes - `backend/runs/service.py`: the inbox attempt is gated on `_harness_has(harness, "inbox")` instead of `harness == "claude"`. harness-claude already declares the cap, so Claude behaves as before. - `sidecar/harness_base.py`: new optional `message(sid, text, rec)` hook. It returns `{"delivered"}`, `{"refused"}`, or `NOT_HANDLED` by default. - `sidecar/routes_runs.py`: `/message` for a non-Claude run calls that hook. A refusal, a missing hook or an exception gives `409 inbox_unavailable`, and the backend falls back to the old force-resume. - The test fixture harness-pi declares `inbox`. New `sidecar/test_message_harness.py`. - Docs: `CLAUDE.md` and `sidecar/README.md`. ## Key decisions - **Gate on the manifest's existing `inbox` cap**, not a hard-coded list. It was already in `CAPS` and declared by harness-claude. - **Safe in any merge order**: with this PR and the old harness-pi, pi has no cap, so behaviour is unchanged. With the new harness-pi and the old core, the backend still gates on Claude, so behaviour is also unchanged. ## Changelog - Changed: a message sent mid-run reaches the running agent for every harness that supports it (Claude Code, and pi with harness-pi 1.2.0), not only Claude Code. ## Test notes - Sidecar, full suite under uv: 689 passed, 6 failed. The same 6 fail on main (test_guard ×4, test_guest_accounts, test_harness_loader evox2). - Backend under bwrap: `test_worker_routing` (covers the Claude inbox path), `test_children`, `test_run_isolation`, `test_worker_attachments`, `test_guest_computers`, `test_guests` and `test_plugin_hubruns` all pass. `test_typed_plugins`: same result as main. - End to end with the real pi: see the ai-agent-plugins PR. - No UI change, so there are no screenshots. **Deploy from the Homelab** after merge (ai-agent deploy + sidecar restart). Nothing is deployed from the EVOX2. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
gabrielvidal self-assigned this 2026-12-02 21:16:48 +01:00
gabrielvidal added 1 commit 2026-12-02 21:16:48 +01:00
The backend tries the live run's inbox for any harness whose plugin declares
the inbox cap (claude, now pi) instead of claude only; the sidecar's
/message hands a non-claude run's message to its driver's new message() hook
(harness_base, NOT_HANDLED by default => 409 inbox_unavailable => the old
force-resume). Needs harness-pi 1.2.0 for pi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gabrielvidal added 2 commits 2026-12-03 08:39:27 +01:00
harness-pi 1.2.0 (#57, now on main) declares the inbox cap, so a resume tries
the live run's /message first. test_custom_run_stamps_and_carries_append_system_prompt
didn't stub it and got the unconfigured sidecar's 503: stub /message with
the sidecar's 404 (nothing live), which sends the turn down the plain resume
the test checks. Also merges current main into pi-steer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner
Merged into `main` as 1f4feb40 by the auto-ship batch https://ai-agent.lab.gabvdl.xyz/conversation/9c004d95-9b08-4286-adcc-4f7d9942d866.
gabrielvidal closed this pull request 2026-12-03 09:01:00 +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#61