Skip to content

Route reasoning effort and Fast mode per turn with Jev (opt-in) - #18

Open
nocell wants to merge 1 commit into
sadfun:mainfrom
nocell:feat/jev-turn-routing
Open

nocell wants to merge 1 commit into
sadfun:mainfrom
nocell:feat/jev-turn-routing

Conversation

@nocell

@nocell nocell commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Opt-in per-message routing of Codex's reasoning effort (and, optionally, Fast mode) with Jev, TypeSafe's decision model, through OpenRouter's Decisions API.

Today effort and speed are one shared setting for everyone using the bot. With WIREBOT_JEV_API_KEY set, Wirebot asks Jev before each user turn how much effort the message needs and passes the answer to turn/start:

  • The choice is made among the levels the selected model reports (supportedReasoningEfforts from model/list), so ultra/max are offered only where Codex offers them. A greeting lands on low, a typo fix on medium, a debugging session on high, a migration design on xhigh, a large research task on ultra.
  • WIREBOT_JEV_FAST=auto adds a second question — is a quick reply worth more than a thorough one — and selects the model's fast service tier (WIREBOT_JEV_FAST_TIER, default fast) through serviceTierForTurn, so the choice never sticks to the thread. Off by default because Fast mode costs more credits.
  • Routing is advisory: a 2.5 s timeout, an API error, an unsupported level, or an unavailable model catalog falls back to the configured settings. Scheduled runs are untouched. Each decision is logged with its probabilities at info level.
  • Jev returns typed answers with calibrated probabilities instead of text, in roughly 0.6–1.5 s per call; the state sent is the message text (capped at 8k chars), whether it starts a new task, the attachment count, and the connector name. README states that message text leaves the host for this feature.

Implementation

  • src/routing/jev.ts: thin client for POST /api/alpha/decisions with zod-validated answers.
  • src/routing/turn-router.ts: builds the questions from the current model's capabilities and maps the answers to TurnStartParams overrides.
  • CodexService gains an optional turnRouting provider, called in parallel with ensureThread for user turns only; its result is spread over the configured turn settings.
  • selectedModel moves from channels/config-fields.ts into CodexConfigService so both callers share it.
  • WIREBOT_JEV_API_KEY joins bridgeOnlyEnvironmentKeys and is scrubbed from Codex subprocess environments like the other credentials.

Testing

  • bun run check (tsc + biome) and bun test pass.
  • Verified live against OpenRouter: the request/response shape, and the routing on a set of sample messages (chit-chat → low, small edit → medium, deploy debugging → high, architecture design → xhigh, three research prompts → ultra with probability 1.0; fast-reply probabilities 0.83–0.90 for short messages vs 0.09–0.54 for real work, hence the 0.7 threshold).

🤖 Generated with Claude Code

Wirebot can now ask Jev, TypeSafe's decision model, to pick the reasoning
effort for each user message instead of using one fixed level for every
conversation. With WIREBOT_JEV_API_KEY set, the message text, whether it
starts a new task, the attachment count and the connector name go to
OpenRouter's Decisions endpoint before turn/start, and the chosen level
(among the ones the selected model reports, from low up to ultra) is
passed as the turn's effort. WIREBOT_JEV_FAST=auto additionally lets Jev
decide per turn whether the fast service tier is worth it, using the
serviceTierForTurn override so the choice never sticks to the thread.

Routing is advisory and opt-in: a timeout, an API error or an unsupported
level falls back to the configured settings, scheduled runs are untouched,
and every decision is logged with its probabilities. The API key is scrubbed
from Codex subprocess environments like the other bridge credentials.
@nocell
nocell force-pushed the feat/jev-turn-routing branch from 5a1533a to 51d3866 Compare September 22, 2026 07:19

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant