|
28 | 28 | build_tool_base_url, |
29 | 29 | get_databricks_token, |
30 | 30 | ) |
31 | | -from ucode.intelligent_routing.claude_hooks import ( |
32 | | - remove_intelligent_routing_hooks, |
33 | | - sync_intelligent_routing_hooks, |
34 | | -) |
35 | 31 | from ucode.launcher import exec_or_spawn |
| 32 | +from ucode.smart_routing.claude_hooks import ( |
| 33 | + remove_smart_routing_hooks, |
| 34 | + sync_smart_routing_hooks, |
| 35 | +) |
36 | 36 | from ucode.state import mark_tool_managed, save_state |
37 | 37 | from ucode.telemetry import agent_version, ucode_version |
38 | 38 | from ucode.tracing import tracing_env |
|
50 | 50 | "backup_path": CLAUDE_BACKUP_PATH, |
51 | 51 | } |
52 | 52 |
|
53 | | -# Per-workspace opt-in flag for Claude Code intelligent routing (state key). |
54 | | -INTELLIGENT_ROUTING_STATE_KEY = "claude_intelligent_routing_enabled" |
| 53 | +# Per-workspace opt-in flag for Claude Code smart routing (state key). |
| 54 | +# Shared across agents: one opt-in enables smart routing for every routing-capable |
| 55 | +# tool (codex, claude), so a workspace turns it on once. Kept identical to |
| 56 | +# codex.SMART_ROUTING_STATE_KEY on purpose. |
| 57 | +SMART_ROUTING_STATE_KEY = "smart_routing_enabled" |
55 | 58 | # Claude Code settings.json hook events ucode manages when routing is enabled; |
56 | 59 | # marked managed so they're tracked/reverted with the rest of ucode's config. |
57 | 60 | CLAUDE_ROUTING_HOOK_EVENTS = ("PreToolUse", "SessionStart", "SubagentStart") |
@@ -230,7 +233,7 @@ def render_overlay( |
230 | 233 | # shows only one row per model. `ucode claude -- --model X` still overrides for |
231 | 234 | # a single session via Claude Code's own --model flag. |
232 | 235 | # |
233 | | - # The one exception is intelligent routing: `route_root_model` pins the |
| 236 | + # The one exception is smart routing: `route_root_model` pins the |
234 | 237 | # router's per-launch pick for the root session as ANTHROPIC_MODEL. The |
235 | 238 | # duplicate-picker-row cost is acceptable because the whole point is to launch |
236 | 239 | # on the routed model rather than the family default. |
@@ -354,29 +357,29 @@ def _unregister_web_search_mcp() -> None: |
354 | 357 | pass |
355 | 358 |
|
356 | 359 |
|
357 | | -def intelligent_routing_enabled(state: dict) -> bool: |
| 360 | +def smart_routing_enabled(state: dict) -> bool: |
358 | 361 | """Return whether the current workspace opted into Claude Code routing.""" |
359 | | - return state.get(INTELLIGENT_ROUTING_STATE_KEY) is True |
| 362 | + return state.get(SMART_ROUTING_STATE_KEY) is True |
360 | 363 |
|
361 | 364 |
|
362 | | -def enable_intelligent_routing(state: dict) -> dict: |
363 | | - """Persist the current workspace's Claude Code intelligent-routing opt-in.""" |
364 | | - state[INTELLIGENT_ROUTING_STATE_KEY] = True |
| 365 | +def enable_smart_routing(state: dict) -> dict: |
| 366 | + """Persist the current workspace's Claude Code smart-routing opt-in.""" |
| 367 | + state[SMART_ROUTING_STATE_KEY] = True |
365 | 368 | return state |
366 | 369 |
|
367 | 370 |
|
368 | | -def disable_intelligent_routing(state: dict) -> bool: |
| 371 | +def disable_smart_routing(state: dict) -> bool: |
369 | 372 | """Disable routing and remove only ucode's Claude Code routing hooks.""" |
370 | | - state.pop(INTELLIGENT_ROUTING_STATE_KEY, None) |
| 373 | + state.pop(SMART_ROUTING_STATE_KEY, None) |
371 | 374 | if state.get("workspace"): |
372 | 375 | save_state(state) |
373 | 376 | changed = False |
374 | 377 | if CLAUDE_SETTINGS_PATH.exists(): |
375 | 378 | doc = read_json_safe(CLAUDE_SETTINGS_PATH) |
376 | | - if remove_intelligent_routing_hooks(doc): |
| 379 | + if remove_smart_routing_hooks(doc): |
377 | 380 | write_json_file(CLAUDE_SETTINGS_PATH, doc) |
378 | 381 | changed = True |
379 | | - from ucode.intelligent_routing.claude_routing import clear_routing_artifacts |
| 382 | + from ucode.smart_routing.claude_routing import clear_routing_artifacts |
380 | 383 |
|
381 | 384 | clear_routing_artifacts() |
382 | 385 | return changed |
@@ -452,11 +455,11 @@ def write_tool_config( |
452 | 455 | if isinstance(merged_env, dict): |
453 | 456 | for key in CLAUDE_REMOVED_ENV_KEYS: |
454 | 457 | merged_env.pop(key, None) |
455 | | - # Intelligent-routing hooks: install ucode's PreToolUse/SessionStart/ |
| 458 | + # Smart-routing hooks: install ucode's PreToolUse/SessionStart/ |
456 | 459 | # SubagentStart hooks when routing is enabled (and not under a provider, |
457 | 460 | # which pins no Databricks model), else surgically strip only ucode's own. |
458 | | - routing_enabled = intelligent_routing_enabled(state) and provider is None |
459 | | - sync_intelligent_routing_hooks(merged, state, enabled=routing_enabled) |
| 461 | + routing_enabled = smart_routing_enabled(state) and provider is None |
| 462 | + sync_smart_routing_hooks(merged, state, enabled=routing_enabled) |
460 | 463 | if routing_enabled: |
461 | 464 | managed_keys = managed_keys + [["hooks", event] for event in CLAUDE_ROUTING_HOOK_EVENTS] |
462 | 465 | write_json_file(CLAUDE_SETTINGS_PATH, merged) |
|
0 commit comments