Skip to content

Add opt-in Codex intelligent routing - #251

Open
rohita5l wants to merge 5 commits into
mainfrom
codex-intelligent-routing
Open

Add opt-in Codex intelligent routing#251
rohita5l wants to merge 5 commits into
mainfrom
codex-intelligent-routing

Conversation

@rohita5l

Copy link
Copy Markdown
Collaborator

Summary

  • add opt-in root-session and subagent model routing for Codex
  • install and remove only ucode-managed hooks through enable/disable flags
  • show routing decisions and record subagent requested/actual models for verification

Testing

  • focused suite: 190 passed
  • Ruff, formatting, type checks, and git diff checks passed
  • full suite: 1048 passed, 36 skipped, 1 unrelated existing Claude binary test failure

rohita5l and others added 3 commits July 29, 2026 20:13
Refactor the Codex smart-routing internals into a harness-agnostic core so a
second agent can reuse them, and rename the feature "intelligent routing" ->
"smart routing" throughout (package dir smart_routing/, symbols, CLI flags
--enable/--disable-smart-routing, hidden codex-router-hook, user-facing
strings) per naming guidance.

- smart_routing/routing.py + hooks.py: shared routes:select call, decision
  shape, canary/audit bookkeeping, and hook add/remove machinery.
- smart_routing/codex_routing.py + codex_hooks.py delegate to the shared core
  (behavior unchanged).
- State key is the agent-neutral "smart_routing_enabled" so a later agent can
  share one opt-in.

Co-authored-by: Isaac
@masonc08
masonc08 force-pushed the codex-intelligent-routing branch from 3d7ce38 to 8b9957f Compare July 31, 2026 18:04
When the user's first prompt is on the command line (`codex "<prompt>"`,
`codex exec "<prompt>"`, or after `--`), route the root-session model on that
actual prompt. A bare interactive launch carries no prompt, so routing is
skipped entirely and the user's configured default model is kept — with no
task signal the router could only return its floor arm, so routing there would
add a round-trip and silently downgrade the default. Routing a typed-in first
prompt is out of scope (no hook/MCP can retarget the root model mid-session on
Codex or Claude Code).

Adds a shared, conservative `extract_seed_prompt` to routing.py: it skips
value-taking options and their values, treats unknown flags as booleans, and
honors the `--` positional separator, returning None (→ skip routing) unless it
is confident it found the prompt.

Co-authored-by: Isaac
@masonc08
masonc08 force-pushed the codex-intelligent-routing branch from a6207dd to 579a5cb Compare July 31, 2026 20:24
Both "Using Smart Routing" messages — the launch-time notice and the
subagent-routing hook's systemMessage — now include the router's rationale, so
the "why" is visible, not just the "what". Previously the launch notice never
showed it and the subagent hook put it only in permissionDecisionReason (a
field the harness doesn't surface in that line). Centralized in
RoutingDecision.display_message() so both paths format identically.

Also persist the rationale in the decisions.jsonl record, so an empty value
cleanly distinguishes "the gateway returned no rationale" from a display-side
placement bug.

Co-authored-by: Isaac
@masonc08
masonc08 force-pushed the codex-intelligent-routing branch from f29d4d0 to db235b4 Compare July 31, 2026 21:18
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.

2 participants