Skip to content

smart routing: route Codex v2 subagents - #409

Open
lilly-luo wants to merge 9 commits into
mainfrom
lilly/codex-subagent
Open

smart routing: route Codex v2 subagents#409
lilly-luo wants to merge 9 commits into
mainfrom
lilly/codex-subagent

Conversation

@lilly-luo

@lilly-luo lilly-luo commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • initialize the Codex PreToolUse spawn-agent routing hook when ENABLE_SMART_ROUTING_V2=1
  • reuse the existing Unity Gateway routing command and pass all cached compatible models
  • preserve existing user PreToolUse hooks while layering the V2 hook into app-server config

Testing

  • .venv/bin/pytest tests/test_codex_smart_routing_v2.py tests/test_codex_routing.py tests/test_agent_codex.py tests/test_lint.py -q
  • .venv/bin/ruff check .
  • full suite: 2,021 passed; remaining failures/errors require local socket permissions unavailable in the sandbox
Screen.Recording.2026-08-28.at.6.40.13.PM.mov

Comment on lines -26 to -28
CODEX_ROUTE_ARMS = ("glm-5-2", "gpt-5-6-sol", "gpt-5-6-luna")
GLM_ROUTE_ARM = "glm-5-2"
GLM_GATEWAY_MODEL = "system.ai.glm-5-2"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im pulling this from model discovery instead now so its dynamic

)

profile = state.get("profile")
os.environ[OAUTH_TOKEN_ENV_VAR] = get_databricks_token(workspace, profile)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Token expiration might prevent the routing here

configured_hooks = doc.get("hooks")
existing = configured_hooks.get("PreToolUse") if isinstance(configured_hooks, dict) else None
return merge_pre_tool_use_hooks(
existing if isinstance(existing, list) else [],

@andy-xu-db andy-xu-db Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the hooks be duplicated here from merging the existing ones with their copy?

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