feat: add persisted manual pi backend mode controls

This commit is contained in:
William Valentin
2026-02-23 23:06:40 -08:00
parent 3e5e82c76e
commit 4188c68130
14 changed files with 360 additions and 10 deletions
+6
View File
@@ -28,6 +28,7 @@ flowchart LR
CA[ChannelAdapters]
GW[Gateway\nHTTP + WS JSON-RPC + Web UI]
RT[Routing\ncreateMessageRouter()]
PF[Preferences\n~/.local/share/flynn/preferences.json\nmodelTier + backendMode]
SM[SessionManager\nSQLite]
OR[AgentOrchestrator]
NA[NativeAgent\n(tool loop)]
@@ -55,6 +56,7 @@ flowchart LR
CG --> RT
CE --> RT
PF --> RT
CH --> CA
GW --> RT
@@ -96,6 +98,9 @@ ChannelAdapter -> ChannelRegistry
| v
| createMessageRouter()
| |
| +----> Runtime backend mode overrides
| (/backend status|activate pi|deactivate pi|use config)
| |
| v
| SessionManager
| |
@@ -134,6 +139,7 @@ Outbound Reply
Key files:
- Routing + per-session agent creation: `src/daemon/routing.ts`
- Runtime preference persistence (`modelTier`, `backendMode`): `src/preferences.ts`
- Orchestration: `src/backends/native/orchestrator.ts`
- Tool loop: `src/backends/native/agent.ts`
- External backend adapters: `src/backends/external.ts`, `src/backends/piEmbedded.ts`
@@ -11,6 +11,7 @@ If you only want the protocol surface, see `docs/api/PROTOCOL.md`.
- Agent work is queued per `sessionId` (FIFO), not per connection.
- Sessions persist in SQLite via `SessionManager` even if clients disconnect.
- Once dequeued, message routing may execute the native orchestrator path or an optional external backend path (`claude_code`, `opencode`, `codex`, `gemini`, `pi_embedded`) depending on agent/backend config.
- Runtime backend mode can be overridden manually via `/backend` command fast-path (`status`, `activate pi`, `deactivate pi`, `use config`) and is persisted in preferences.
- Backend routing outcomes are auditable via `backend.route` / `backend.success` / `backend.fallback`, which enables offline canary evaluation without changing gateway protocol methods.
## Component Map
@@ -19,6 +20,7 @@ If you only want the protocol surface, see `docs/api/PROTOCOL.md`.
flowchart LR
subgraph CFG[Config + Runtime Policy]
QP[server.queue policy\nmode/cap/overflow/overrides]
BM[backend runtime mode\nconfig_default|force_native|force_pi_embedded]
end
subgraph GW[Gateway Process]
@@ -37,6 +39,7 @@ flowchart LR
WS --> GS
QP --> GS
BM --> GS
GS --> LQ
GS --> SB
LQ --> AQ