feat(plugins): handoffs leave the core for the Handoff plugin #7

Closed
gabrielvidal wants to merge 0 commits from handoff-plugin into main
pull from: handoff-plugin
Owner

Summary

Handoffs (continue a conversation in a new one on another model, harness or machine) leave the core for the new Handoff live plugin (ai-agent-plugins → plugins/handoff, its own PR). The core forgets handoffs entirely, link included (Gabriel's picks in form handoff-plugin-move_ryvcho: scope B, menu B, dialog A, banners A, skill B). What the core gains in exchange is generic: plugin rows in the conversation menu that open a plugin dialog, two thread slot places, and a bridge for a plugin's own data on a conversation.

Companion PRs: the plugin — gabrielvidal/ai-agent-plugins#1 · the homelab skill copy deleted — gabrielvidal/homelab#17.

Key changes

  • ui.menuItems[] (plugins/manifest.py _menu_items, plugins/routes.py): {id, where: "conversation.menu", label, icon?, html, height?, title?}, ≤ 8, only written when set (approval fingerprint unchanged for every other plugin). Served in /api/plugins/ui and at GET /api/plugins/{pid}/ui/menuItem/{id}.
  • Conversation menu (ConversationMenu.tsx, new business/plugins/components/PluginMenuItems.tsx): Hand off ▸ and its model rows are gone; each active plugin's item is a row that opens its sandboxed frame in a Modal, init {conversationId, sessionId, title, harness, worker, running, archived}.
  • Frame bridges (PluginSandboxFrame.tsx): aiAgentPlugin.close() (closes the dialog it is in) and aiAgentPlugin.toast(message, tone) (provider-safe, like ResourceTags).
  • Thread places conversation.threadHeader (first line, under the fork banner) and conversation.threadEnd (last line, after the summary): ThreadPluginSlots feeds each slot {sessionId, conversationId, running, pluginData}, where pluginData is that plugin's own meta.plugins.<id>.
  • ConversationDetail.pluginData (owner only) and the new conversations.data capability (plugins/hubconvdata.py): GET|POST …/hub/conversations/{sid}/data, plugin handlers only, owner only, operator approval, ≤ 16 KB, merge or replace, SSE meta after a write.
  • runs.start takes test: true; hub/conversations rows carry model and harness.
  • Carry-over carryover.handoffs: the old meta.handoffFrom / handoffTo stamps (2026-11-24 → 26) are copied into meta.plugins.handoff.from / .to at start, so past handoffs keep their banners.
  • Removed: runs/handoff.py, POST /api/handoff (+ authz row, golden matrix, fr string), SpawnBody.handoffFrom and the spawn's handoff origin, meta.handoffFrom/handoffTo in cards, handoff*Conversation in spawned.links, the Handoff* schemas and generated models, Handoff.tsx + test, the Handoffs eye switch (the plugin's own vis switch replaces it), 16 unused fr strings.
  • CLI / MCP: ai-agent new --handoff-from and MCP start_conversation.handoff_from removed, with their tests; the plugin's commands replace them.
  • Docs: docs/plugins.md → "Menu items, thread places and conversation data", the capability table; CLAUDE.md → "Handoffs" rewritten.

Key decisions

  • The link moved too (scope B): the plugin stores both ends as its own data through conversations.data, instead of the core keeping a handoffFrom spawn field. The bridge, menu items and thread places know nothing about handoffs, so any plugin can use them.
  • Slots get their plugin's data in update, not through a handler read: a conversation with no handoff costs no subprocess (the slot folds with resize(0)); only the Continued in banner peeks (once synced) for the successor's id and title.
  • conversations.data is handler-only: the owner's run token can't write it directly; the plugin's link action holds the rules (both ends, ownership, shapes).
  • CLI / MCP through the plugin's commands (the mechanism of 299c27e7, conversation 9a264493): ai-agent new --handoff-from and MCP start_conversation.handoff_from are removed. The plugin declares ai-agent plugin handoff start|link|links|models and the MCP tools plugin_handoff_start / _link / _links itself. A worker-bound MCP connection gets no plugin tools, so on a Mac the skill's handoff link calls the plugin's action through hub.json, where an owner's worker token is the owner.
  • Telemetry keeps reading the stamped meta.origin == "handoff" for the old runs, without reading any handoff meta.

Changelog

  • Changed: Hand off is now a plugin — the conversation menu's Hand off… opens the Handoff plugin's dialog (model, who writes the brief, a note); its banners Continued from / Continued in and their Handoffs switch come with the plugin.
  • Added: plugins can add rows to the conversation menu that open their own dialog, draw on the thread's first and last line, and keep their own data on a conversation.
  • Removed: the built-in hand-off menu, dialog and banners (the Handoff plugin replaces them; past handoffs keep their links).
  • Removed: ai-agent new --handoff-from and the MCP handoff_from argument — use ai-agent plugin handoff start|link (MCP plugin_handoff_start / plugin_handoff_link).

Test notes

  • Rebased on main 299c27e7 (plugin commands). CLI: test_ai_agent.py + test_mcp_tools.py 75 passed. The plugin's commands were driven through this branch's ai-agent plugin handoff … against the real backend: commands lists the four with their MCP tool names, links resolves the successor once synced, models, start reaches the run bridge, a bad --mode is refused, and new --handoff-from is now an unknown flag. After the rebase, test_plugin_conv_data, test_plugins, test_authz_matrix, test_plugin_widget_platform, test_plugin_hubruns and test_plugin_commands all pass; the re-dumped spec and generated types are unchanged; tsc is clean.
  • Backend, in a container with /data on tmpfs (as scripts/test.py): new test_plugin_conv_data.py (12 passed). test_authz_matrix, test_authz, test_telemetry, test_plugin_hubruns, test_plugin_widget_platform, test_plugins, test_children, test_spawned_live, test_plugin_conversations, test_continued_in, test_conv_uid_routes, test_batch1_platform, test_stage2_platform, test_plugin_gaps and test_typed_plugins each pass the same as on main, one module per process.
  • Frontend: tsc --noEmit clean; vitest 1 035 passed + the new PluginMenuItems.test.tsx (3). The 3 failures are pre-existing: FreshContext is on the known-flaky list, and the 2 useShareTarget tests fail identically on main on the EVOX2 (object.stream is not a function).
  • End to end on the real backend (uvicorn, host network, the plugin installed and approved, a fixture transcript as the source): menu item and slots listed, dialog html served, carry-over of an old stamp, link stamping both ends, pluginData in the source's detail, peek (synced / not yet), models (with vendors), warm → conversations.send and cold → runs.start reached (a clean 503: no sidecar on the devbox), a bad mode → 400. All passed.
  • Screenshots below: the built frontend served by dev-up --dist over that backend (dark): the menu row, the dialog, Continued in, Continued from.
  • Ship order (from the Homelab, never from the EVOX2): install and approve the plugin (ai-agent plugin install ~/projects/ai-agent-plugins/plugins/handoff --approve, operator capabilities conversations.send, runs.start, models.read, conversations.data), deploy this PR (ai-agent-deploy), then merge the homelab PR. Between the core deploy and the plugin install there is no Hand off menu, and no banners.

🤖 Generated with Claude Code

Screenshots

2-menu.png
3-dialog.png
1-continued-in.png
4-continued-from.png

## Summary Handoffs (continue a conversation in a new one on another model, harness or machine) leave the core for the new **Handoff** live plugin (`ai-agent-plugins` → `plugins/handoff`, its own PR). The core forgets handoffs entirely, link included (Gabriel's picks in form `handoff-plugin-move_ryvcho`: scope B, menu B, dialog A, banners A, skill B). What the core gains in exchange is generic: plugin rows in the conversation menu that open a plugin dialog, two thread slot places, and a bridge for a plugin's own data on a conversation. Companion PRs: the plugin — https://git.gabvdl.xyz/gabrielvidal/ai-agent-plugins/pulls/1 · the homelab skill copy deleted — https://git.gabvdl.xyz/gabrielvidal/homelab/pulls/17. ## Key changes - **`ui.menuItems[]`** (`plugins/manifest.py` `_menu_items`, `plugins/routes.py`): `{id, where: "conversation.menu", label, icon?, html, height?, title?}`, ≤ 8, only written when set (approval fingerprint unchanged for every other plugin). Served in `/api/plugins/ui` and at `GET /api/plugins/{pid}/ui/menuItem/{id}`. - **Conversation menu** (`ConversationMenu.tsx`, new `business/plugins/components/PluginMenuItems.tsx`): *Hand off ▸* and its model rows are gone; each active plugin's item is a row that opens its sandboxed frame in a Modal, init `{conversationId, sessionId, title, harness, worker, running, archived}`. - **Frame bridges** (`PluginSandboxFrame.tsx`): `aiAgentPlugin.close()` (closes the dialog it is in) and `aiAgentPlugin.toast(message, tone)` (provider-safe, like `ResourceTags`). - **Thread places** `conversation.threadHeader` (first line, under the fork banner) and `conversation.threadEnd` (last line, after the summary): `ThreadPluginSlots` feeds each slot `{sessionId, conversationId, running, pluginData}`, where `pluginData` is **that plugin's own** `meta.plugins.<id>`. - **`ConversationDetail.pluginData`** (owner only) and the new **`conversations.data`** capability (`plugins/hubconvdata.py`): `GET|POST …/hub/conversations/{sid}/data`, plugin handlers only, owner only, operator approval, ≤ 16 KB, merge or replace, SSE `meta` after a write. - `runs.start` takes `test: true`; `hub/conversations` rows carry `model` and `harness`. - **Carry-over** `carryover.handoffs`: the old `meta.handoffFrom` / `handoffTo` stamps (2026-11-24 → 26) are copied into `meta.plugins.handoff.from` / `.to` at start, so past handoffs keep their banners. - **Removed**: `runs/handoff.py`, `POST /api/handoff` (+ authz row, golden matrix, fr string), `SpawnBody.handoffFrom` and the spawn's `handoff` origin, `meta.handoffFrom/handoffTo` in cards, `handoff*Conversation` in `spawned.links`, the `Handoff*` schemas and generated models, `Handoff.tsx` + test, the *Handoffs* eye switch (the plugin's own `vis` switch replaces it), 16 unused fr strings. - **CLI / MCP**: `ai-agent new --handoff-from` and MCP `start_conversation.handoff_from` removed, with their tests; the plugin's commands replace them. - Docs: `docs/plugins.md` → "Menu items, thread places and conversation data", the capability table; `CLAUDE.md` → "Handoffs" rewritten. ## Key decisions - **The link moved too (scope B):** the plugin stores both ends as its own data through `conversations.data`, instead of the core keeping a `handoffFrom` spawn field. The bridge, menu items and thread places know nothing about handoffs, so any plugin can use them. - **Slots get their plugin's data in `update`**, not through a handler read: a conversation with no handoff costs no subprocess (the slot folds with `resize(0)`); only the *Continued in* banner peeks (once synced) for the successor's id and title. - **`conversations.data` is handler-only:** the owner's run token can't write it directly; the plugin's `link` action holds the rules (both ends, ownership, shapes). - **CLI / MCP through the plugin's `commands`** (the mechanism of 299c27e7, conversation 9a264493): `ai-agent new --handoff-from` and MCP `start_conversation.handoff_from` are removed. The plugin declares `ai-agent plugin handoff start|link|links|models` and the MCP tools `plugin_handoff_start` / `_link` / `_links` itself. A worker-bound MCP connection gets no plugin tools, so on a Mac the skill's `handoff link` calls the plugin's action through `hub.json`, where an owner's worker token is the owner. - Telemetry keeps reading the stamped `meta.origin == "handoff"` for the old runs, without reading any handoff meta. ## Changelog - Changed: *Hand off* is now a plugin — the conversation menu's **Hand off…** opens the Handoff plugin's dialog (model, who writes the brief, a note); its banners *Continued from* / *Continued in* and their *Handoffs* switch come with the plugin. - Added: plugins can add rows to the conversation menu that open their own dialog, draw on the thread's first and last line, and keep their own data on a conversation. - Removed: the built-in hand-off menu, dialog and banners (the Handoff plugin replaces them; past handoffs keep their links). - Removed: `ai-agent new --handoff-from` and the MCP `handoff_from` argument — use `ai-agent plugin handoff start|link` (MCP `plugin_handoff_start` / `plugin_handoff_link`). ## Test notes - Rebased on `main` 299c27e7 (plugin commands). CLI: `test_ai_agent.py` + `test_mcp_tools.py` 75 passed. The plugin's commands were driven through this branch's `ai-agent plugin handoff …` against the real backend: `commands` lists the four with their MCP tool names, `links` resolves the successor once synced, `models`, `start` reaches the run bridge, a bad `--mode` is refused, and `new --handoff-from` is now an unknown flag. After the rebase, `test_plugin_conv_data`, `test_plugins`, `test_authz_matrix`, `test_plugin_widget_platform`, `test_plugin_hubruns` and `test_plugin_commands` all pass; the re-dumped spec and generated types are unchanged; `tsc` is clean. - Backend, in a container with `/data` on tmpfs (as `scripts/test.py`): new `test_plugin_conv_data.py` (12 passed). `test_authz_matrix`, `test_authz`, `test_telemetry`, `test_plugin_hubruns`, `test_plugin_widget_platform`, `test_plugins`, `test_children`, `test_spawned_live`, `test_plugin_conversations`, `test_continued_in`, `test_conv_uid_routes`, `test_batch1_platform`, `test_stage2_platform`, `test_plugin_gaps` and `test_typed_plugins` each pass the same as on `main`, one module per process. - Frontend: `tsc --noEmit` clean; vitest 1 035 passed + the new `PluginMenuItems.test.tsx` (3). The 3 failures are pre-existing: `FreshContext` is on the known-flaky list, and the 2 `useShareTarget` tests fail identically on `main` on the EVOX2 (`object.stream is not a function`). - **End to end** on the real backend (uvicorn, host network, the plugin installed and approved, a fixture transcript as the source): menu item and slots listed, dialog html served, carry-over of an old stamp, `link` stamping both ends, `pluginData` in the source's detail, `peek` (synced / not yet), `models` (with vendors), warm → `conversations.send` and cold → `runs.start` reached (a clean 503: no sidecar on the devbox), a bad mode → 400. All passed. - Screenshots below: the built frontend served by `dev-up --dist` over that backend (dark): the menu row, the dialog, *Continued in*, *Continued from*. - Ship order (from the Homelab, never from the EVOX2): install and approve the plugin (`ai-agent plugin install ~/projects/ai-agent-plugins/plugins/handoff --approve`, operator capabilities `conversations.send`, `runs.start`, `models.read`, `conversations.data`), deploy this PR (`ai-agent-deploy`), then merge the homelab PR. Between the core deploy and the plugin install there is no Hand off menu, and no banners. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ## Screenshots ![2-menu.png](https://git.gabvdl.xyz/attachments/2392abce-5618-42b1-980a-157179dab7f0) ![3-dialog.png](https://git.gabvdl.xyz/attachments/525fce03-aa56-40a2-8d8d-31a2771aa9a8) ![1-continued-in.png](https://git.gabvdl.xyz/attachments/e6be2b63-eb52-4b06-b316-eb078cd8e1ae) ![4-continued-from.png](https://git.gabvdl.xyz/attachments/a6c86bed-ab6c-4509-816e-1adf87fb69ec)
gabrielvidal self-assigned this 2026-11-26 23:12:34 +01:00
gabrielvidal added 2 commits 2026-11-26 23:24:07 +01:00
The handoff link, the conversation menu's Hand off ▸, HandoffDialog, the
Continued from / Continued in banners and POST /api/handoff move to the
handoff live plugin (ai-agent-plugins). What the core keeps is generic:

- ui.menuItems (conversation.menu): a plugin row in the conversation menu
  opening the plugin's sandboxed dialog; frame bridges close() and toast()
- slot places conversation.threadHeader / conversation.threadEnd, whose
  update carries the plugin's own meta.plugins.<id> (pluginData)
- ConversationDetail.pluginData (owner only)
- conversations.data: GET|POST hub/conversations/{sid}/data, a plugin's
  own data on a conversation (handler only, owner only, operator approval)
- runs.start takes test; hub/conversations rows carry model and harness
- carryover.handoffs moves the old meta.handoffFrom / handoffTo stamps
  into meta.plugins.handoff once

Removed: runs/handoff.py, /api/handoff, SpawnBody.handoffFrom and the
spawn's handoff origin, meta.handoffFrom/handoffTo and their resolved refs,
Handoff.tsx, the Handoffs eye switch (the plugin's vis switch replaces it).
The CLI's --handoff-from and MCP handoff_from are left alone (inert) until
the CLI/MCP plugin-commands mechanism lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The plugin-commands mechanism is live (299c27e7): the Handoff plugin declares
its own CLI commands and MCP tools (ai-agent plugin handoff start|link|links|
models; plugin_handoff_start/_link/_links), so the core's inert --handoff-from
flag and start_conversation.handoff_from leave, with their tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gabrielvidal force-pushed handoff-plugin from 9b12362c79 to f038c4fa20 2026-11-26 23:24:07 +01:00 Compare
Author
Owner

Merged into main as 4e90149b (batch merge of the EVOX2 conversations, all ai-agent suites green) and deployed: ai-agent @ e1b7b4ab live since 2026-11-26 23:41.

Merged into `main` as 4e90149b (batch merge of the EVOX2 conversations, all ai-agent suites green) and deployed: ai-agent @ e1b7b4ab live since 2026-11-26 23:41.
gabrielvidal closed this pull request 2026-11-26 23:44:05 +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#7