Add opt-in Codex intelligent routing - #251
Open
rohita5l wants to merge 5 commits into
Open
Conversation
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
force-pushed
the
codex-intelligent-routing
branch
from
July 31, 2026 18:04
3d7ce38 to
8b9957f
Compare
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
force-pushed
the
codex-intelligent-routing
branch
from
July 31, 2026 20:24
a6207dd to
579a5cb
Compare
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
force-pushed
the
codex-intelligent-routing
branch
from
July 31, 2026 21:18
f29d4d0 to
db235b4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing