supervisor: openrouter runtime — the key.store harness on an OpenAI-compatible router #11

Merged
founder merged 1 commit from openrouter-runtime into main 2026-09-06 21:07:38 +00:00
Owner

A third resident runtime, openrouter (aliases router, openai-compatible, harness): a pi-style agent loop built into the supervisor instead of an external CLI, so GLM and Kimi residents run through OpenRouter today and the key.store router later (base URL + profile switch, same key file).

  • internal/openaichat: chat-completions client — retry on 429/408/5xx with backoff, content parts, 200+error bodies, provider routing ({"order":[…],"allow_fallbacks":false}), reasoning echoed back as reasoning+reasoning_details on OpenRouter / reasoning_content on vanilla routers (Kimi rejects a history without it).
  • internal/mcphttp: Streamable-HTTP MCP client for the forge hub (JSON or SSE bodies, Mcp-Session-Id, re-initialize on 404, cursor pagination).
  • internal/harness: jsonl sessions (session/message/usage/compaction lines) with compaction at 75 % of the context window that never splits a tool call from its result, plus a hand-off digest; read_file/write_file/edit_file/list_dir/bash tools (writes only under the checkout + writable roots, read-deny prefixes) plus every hub tool the identity token allows; steers drained between tool calls; a bubblewrap sandbox with the Codex workspace-write shape (ro root, fresh /dev,/proc,/run, secret stores and other identities' state masked, checkout + notebook + /tmp writable, user/pid/ipc/uts namespaces, all caps dropped, network on; still uid 0 — KSE-0181 uid drop is the follow-up).
  • agentdispatcher: routerClient implementing residentClient + resume/compact/digest; org tiers gain context_window and provider_order; supervisor flags --router-base-url/--router-api-key-file/--router-state-dir/--router-sandbox/--router-title/--router-referer/--router-context-window/--router-profile (env AGENT_DISPATCHER_ROUTER_*); requeue rule router-runtime while the key file is absent.

Tests: go test ./... green (fake model + fake hub round trips: tool call via the hub, reasoning echo, resume, digest, recoverable failures; sandbox argv shape; MCP SSE/JSON/expired-session; chat client retry/parts/embedded error/profiles).

key.store side (separate PR): agentDispatcher.router.* module options, org tiers openrouter-glm / openrouter-kimi, docs; the forge key openrouter/api-key is declared behind openrouterEnabled until the founder writes it to OpenBao.

A third resident runtime, `openrouter` (aliases `router`, `openai-compatible`, `harness`): a pi-style agent loop built into the supervisor instead of an external CLI, so GLM and Kimi residents run through OpenRouter today and the key.store router later (base URL + profile switch, same key file). - `internal/openaichat`: chat-completions client — retry on 429/408/5xx with backoff, content parts, 200+error bodies, provider routing (`{"order":[…],"allow_fallbacks":false}`), reasoning echoed back as `reasoning`+`reasoning_details` on OpenRouter / `reasoning_content` on vanilla routers (Kimi rejects a history without it). - `internal/mcphttp`: Streamable-HTTP MCP client for the forge hub (JSON or SSE bodies, `Mcp-Session-Id`, re-initialize on 404, cursor pagination). - `internal/harness`: jsonl sessions (`session`/`message`/`usage`/`compaction` lines) with compaction at 75 % of the context window that never splits a tool call from its result, plus a hand-off digest; `read_file`/`write_file`/`edit_file`/`list_dir`/`bash` tools (writes only under the checkout + writable roots, read-deny prefixes) plus every hub tool the identity token allows; steers drained between tool calls; a bubblewrap sandbox with the Codex workspace-write shape (ro root, fresh /dev,/proc,/run, secret stores and other identities' state masked, checkout + notebook + /tmp writable, user/pid/ipc/uts namespaces, all caps dropped, network on; still uid 0 — KSE-0181 uid drop is the follow-up). - `agentdispatcher`: `routerClient` implementing residentClient + resume/compact/digest; org tiers gain `context_window` and `provider_order`; supervisor flags `--router-base-url/--router-api-key-file/--router-state-dir/--router-sandbox/--router-title/--router-referer/--router-context-window/--router-profile` (env `AGENT_DISPATCHER_ROUTER_*`); requeue rule `router-runtime` while the key file is absent. Tests: `go test ./...` green (fake model + fake hub round trips: tool call via the hub, reasoning echo, resume, digest, recoverable failures; sandbox argv shape; MCP SSE/JSON/expired-session; chat client retry/parts/embedded error/profiles). key.store side (separate PR): `agentDispatcher.router.*` module options, org tiers `openrouter-glm` / `openrouter-kimi`, docs; the forge key `openrouter/api-key` is declared behind `openrouterEnabled` until the founder writes it to OpenBao.
founder force-pushed openrouter-runtime from ffc7e5ce52 to 543da93839 2026-09-06 21:07:35 +00:00 Compare
founder deleted branch openrouter-runtime 2026-09-06 21:07:39 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
key-store/dispatch!11
No description provided.