feat(routing): move model ladders to runs.route plugin hook & single composer setting #57

Closed
gabrielvidal wants to merge 0 commits from agent-presets into main
pull from: agent-presets
Owner

Summary

Moves ai-agent's model ladder features out of core into a generic runs.route live-plugin provider hook (implemented by the seeded agent-presets plugin), adds custom additional system prompt support (appendSystemPrompt) across all harnesses, and replaces the spawn composer's separate model/account/machine/effort chips with a single Agent Preset setting featuring a Presets | Custom tabbed popover.

Key changes

  • Generic runs.route plugin hook (backend/plugins/run_router.py, backend/plugins/manifest.py): Delegates brief, resolve, turn, and subagent routing operations to the owner's enabled runs.route plugin, exposes GET /api/plugins/run-presets (SSE run-presets), and provides owner-only models.read bridges GET …/hub/routing/state and POST …/hub/routing/check for batched route evaluation.
  • Core ladder removal & carryover: Deleted backend/models/ladders.py, /api/model-ladders* routes, frontend/src/lib/ladders.tsx, Presets.tsx, Preset.tsx, and core RoutingCard.tsx. Added one-time carryover from /data/model-ladders.json into the agent-presets plugin (backend/plugins/carryover.py). /api/models and hub/models keep populating ladders / ladderDefaults via run_router.brief for plugin compatibility.
  • Universal appendSystemPrompt & auto-continue plumbing (backend/runs/routes.py, service.py, plugins/hubruns.py, proxyroutes.py, sidecar_client.py): Added appendSystemPrompt (max 16k chars) to /api/spawn, /api/resume, hub/runs, and hub/conversations/{sid}/send, forwarded to all harnesses and persisted in conversation metadata; added compact/fresh/restart support to hub/conversations/{sid}/send, enriched conversation.finished with preset/route fields, and added ?digest=1 transcript digest support to hub/conversations/{sid}.
  • Single composer setting with Presets | Custom popover (frontend/src/business/composer/components/AgentPresetPicker.tsx, SpawnComposer.tsx): When a runs.route provider is active, the owner's composer collapses Model, Account, Machine, Effort/Thinking, and Profile into one chip (Best · … or Custom · …), keeping Chrome, Code Mode, and Usage rings alongside it. The popover offers a Presets tab (live resolved routes, machine/prompt badges, Manage presets →) and a Custom tab (Harness, Model + OpenRouter browser, Effort/Thinking, Machine, Account, Additional system prompt, and inline Save as preset). Reply composer keeps its existing Model + Effort chips.
  • Settings & Conversation integration (Models.tsx, Conversation.tsx, ConvMetaBits.tsx, redirects.tsx): Settings → Models shows a link banner to Agent presets; /settings/models/presets/:presetId redirects via plugin opener; Details Routing card is handed off to the plugin's conversation.details slot.
  • OpenAPI & docs: Regenerated frontend/openapi.json and frontend/src/generated/, updated CLAUDE.md and docs/plugins.md.

Key decisions

  • Generic runs.route contract over hardcoded plugin calls: Mirrors runs.limits and composer.beforeSend so core stays plugin-agnostic and degrades cleanly to standard pickers when no routing plugin is enabled.
  • Hub-side batched route evaluation (hub/routing/check): Keeps route_new_run as the single source of truth for profile/worker/account rules instead of duplicating worker routing logic inside the plugin.
  • Two-tab popover (Presets | Custom) + kept toggles: Follows Gabriel's answers in form agent-presets-plugin_j5wxui — keeps the toolbar uncluttered at one routing chip while leaving Chrome, Code Mode, and Usage rings immediately accessible.
  • Companion PR: Requires https://git.gabvdl.xyz/gabrielvidal/ai-agent-plugins/pulls/52 (agent-presets plugin and harness appendSystemPrompt updates).

Changelog

  • Added: Single composer preset setting with a Presets | Custom popover to pick a preset or manually configure harness, model, effort, machine, account, and an additional system prompt (with inline Save as preset).
  • Added: Additional system prompt support across all harnesses (claude, pi, opencode, agy).
  • Changed: Moved model ladders, preset editing, and the conversation Routing Details card out of core into the seeded agent-presets live plugin via a generic runs.route provider hook.

Test notes

  • Backend: uv run --with-requirements requirements.txt python -m unittest test_run_router test_authz test_plugins test_plugin_hubruns test_plugin_schedule test_plugin_conversations test_worker_routing test_model_presets test_fresh_context_migration test_run_queue test_models_availability test_run_isolation — 205/205 passed (including updated authz golden matrix).
  • Live E2E integration: verified real FastAPI hub installing and invoking the real agent-presets plugin subprocess over HTTP (/api/plugins/run-presets, actions/update, and runs.service._send_message with preset:best + custom appendSystemPrompt).
  • Frontend: npx tsc --noEmit (0 errors), npx vitest run (188 files / 1,222 tests passed), npm run build (clean PWA build).
  • Visual verification: captured mock-backend screenshots of the Home composer single chip, Presets tab, Custom tab, and updated Settings → Models page (attached below).
  • Not deployed from EVOX2 — deploy from the Homelab after reviewing and merging both this PR and the companion ai-agent-plugins PR.

Screenshots

shot-home.png
shot-presets-tab.png
shot-custom-tab.png
shot-models.png

## Summary Moves `ai-agent`'s model ladder features out of core into a generic `runs.route` live-plugin provider hook (implemented by the seeded `agent-presets` plugin), adds custom additional system prompt support (`appendSystemPrompt`) across all harnesses, and replaces the spawn composer's separate model/account/machine/effort chips with a single Agent Preset setting featuring a **Presets | Custom** tabbed popover. ## Key changes - **Generic `runs.route` plugin hook (`backend/plugins/run_router.py`, `backend/plugins/manifest.py`)**: Delegates `brief`, `resolve`, `turn`, and `subagent` routing operations to the owner's enabled `runs.route` plugin, exposes `GET /api/plugins/run-presets` (SSE `run-presets`), and provides owner-only `models.read` bridges `GET …/hub/routing/state` and `POST …/hub/routing/check` for batched route evaluation. - **Core ladder removal & carryover**: Deleted `backend/models/ladders.py`, `/api/model-ladders*` routes, `frontend/src/lib/ladders.tsx`, `Presets.tsx`, `Preset.tsx`, and core `RoutingCard.tsx`. Added one-time carryover from `/data/model-ladders.json` into the `agent-presets` plugin (`backend/plugins/carryover.py`). `/api/models` and `hub/models` keep populating `ladders` / `ladderDefaults` via `run_router.brief` for plugin compatibility. - **Universal `appendSystemPrompt` & auto-continue plumbing (`backend/runs/routes.py`, `service.py`, `plugins/hubruns.py`, `proxyroutes.py`, `sidecar_client.py`)**: Added `appendSystemPrompt` (max 16k chars) to `/api/spawn`, `/api/resume`, `hub/runs`, and `hub/conversations/{sid}/send`, forwarded to all harnesses and persisted in conversation metadata; added `compact`/`fresh`/`restart` support to `hub/conversations/{sid}/send`, enriched `conversation.finished` with preset/route fields, and added `?digest=1` transcript digest support to `hub/conversations/{sid}`. - **Single composer setting with Presets | Custom popover (`frontend/src/business/composer/components/AgentPresetPicker.tsx`, `SpawnComposer.tsx`)**: When a `runs.route` provider is active, the owner's composer collapses Model, Account, Machine, Effort/Thinking, and Profile into one chip (`Best · …` or `Custom · …`), keeping Chrome, Code Mode, and Usage rings alongside it. The popover offers a **Presets** tab (live resolved routes, machine/prompt badges, *Manage presets →*) and a **Custom** tab (Harness, Model + OpenRouter browser, Effort/Thinking, Machine, Account, Additional system prompt, and inline *Save as preset*). Reply composer keeps its existing Model + Effort chips. - **Settings & Conversation integration (`Models.tsx`, `Conversation.tsx`, `ConvMetaBits.tsx`, `redirects.tsx`)**: Settings → Models shows a link banner to Agent presets; `/settings/models/presets/:presetId` redirects via plugin opener; Details *Routing* card is handed off to the plugin's `conversation.details` slot. - **OpenAPI & docs**: Regenerated `frontend/openapi.json` and `frontend/src/generated/`, updated `CLAUDE.md` and `docs/plugins.md`. ## Key decisions - **Generic `runs.route` contract over hardcoded plugin calls**: Mirrors `runs.limits` and `composer.beforeSend` so core stays plugin-agnostic and degrades cleanly to standard pickers when no routing plugin is enabled. - **Hub-side batched route evaluation (`hub/routing/check`)**: Keeps `route_new_run` as the single source of truth for profile/worker/account rules instead of duplicating worker routing logic inside the plugin. - **Two-tab popover (`Presets` | `Custom`) + kept toggles**: Follows Gabriel's answers in form `agent-presets-plugin_j5wxui` — keeps the toolbar uncluttered at one routing chip while leaving Chrome, Code Mode, and Usage rings immediately accessible. - **Companion PR**: Requires `https://git.gabvdl.xyz/gabrielvidal/ai-agent-plugins/pulls/52` (`agent-presets` plugin and harness `appendSystemPrompt` updates). ## Changelog - Added: Single composer preset setting with a **Presets | Custom** popover to pick a preset or manually configure harness, model, effort, machine, account, and an additional system prompt (with inline *Save as preset*). - Added: Additional system prompt support across all harnesses (`claude`, `pi`, `opencode`, `agy`). - Changed: Moved model ladders, preset editing, and the conversation Routing Details card out of core into the seeded `agent-presets` live plugin via a generic `runs.route` provider hook. ## Test notes - Backend: `uv run --with-requirements requirements.txt python -m unittest test_run_router test_authz test_plugins test_plugin_hubruns test_plugin_schedule test_plugin_conversations test_worker_routing test_model_presets test_fresh_context_migration test_run_queue test_models_availability test_run_isolation` — 205/205 passed (including updated authz golden matrix). - Live E2E integration: verified real FastAPI hub installing and invoking the real `agent-presets` plugin subprocess over HTTP (`/api/plugins/run-presets`, `actions/update`, and `runs.service._send_message` with `preset:best` + custom `appendSystemPrompt`). - Frontend: `npx tsc --noEmit` (0 errors), `npx vitest run` (188 files / 1,222 tests passed), `npm run build` (clean PWA build). - Visual verification: captured mock-backend screenshots of the Home composer single chip, Presets tab, Custom tab, and updated Settings → Models page (attached below). - Not deployed from EVOX2 — deploy from the Homelab after reviewing and merging both this PR and the companion `ai-agent-plugins` PR. ## Screenshots ![shot-home.png](https://git.gabvdl.xyz/attachments/72b125bc-1e38-44ee-92fd-e3aba22df4ca) ![shot-presets-tab.png](https://git.gabvdl.xyz/attachments/fbf28f2c-e74a-41bc-aae3-28d189159f03) ![shot-custom-tab.png](https://git.gabvdl.xyz/attachments/ef0ee1a9-29d8-490d-8003-46013c0de171) ![shot-models.png](https://git.gabvdl.xyz/attachments/d58b2afd-4be3-433b-a22a-a3a89af77c03)
gabrielvidal self-assigned this 2026-12-02 10:23:59 +01:00
gabrielvidal added 1 commit 2026-12-02 10:23:59 +01:00
Author
Owner
Merged into `main` as a003d8c4 by the auto-ship batch https://ai-agent.lab.gabvdl.xyz/conversation/01a23615-8549-7d18-917c-fe1a7ecda520.
gabrielvidal closed this pull request 2026-12-02 10:55:30 +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#57