Skip to content

[Debug] Log routes:select requests to ~/.ucode/routing-requests.jsonl - #1140

Draft
xsh310 wants to merge 1 commit into
databricks:mainfrom
xsh310:debug-log-routing-requests
Draft

xsh310 wants to merge 1 commit into
databricks:mainfrom
xsh310:debug-log-routing-requests

Conversation

@xsh310

@xsh310 xsh310 commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Debug aid: every routes:select call ug makes now appends one JSON line to ~/.ucode/routing-requests.jsonl with the URL and the exact request body (route_options, task.prompt, route_selector.router_name). This shows the real menu ug sends for the Claude first prompt, Claude subagents, and Codex, so it can be replayed against an AI Gateway LiteSwap (testing databricks-eng/universe#2807774).

{"at": 1792089748.1, "url": "https://<workspace>/ai-gateway/routing/v1/routes:select", "body": {"route_options": [{"model": "claude-opus-4-8", "harness": "claude"}], "task": {"prompt": "..."}, "route_selector": {"router_name": "task_v3"}}}
  • routing.select_route is the single call site for all three menus, so the log lives there.
  • It writes to a file, not stdout, because stdout belongs to the TUI and the hook protocol.
  • The bearer token is not recorded. Request headers and routing behavior are unchanged.
  • The path resolves from config_io.APP_DIR per call, so the test suite's autouse fixture keeps it in a tmp dir.

Draft and not meant to merge as is: logging is always on, unbounded, and writes prompt text to disk.

Try it locally

uv tool install --force --python 3.12 "git+https://github.com/xsh310/ucode@debug-log-routing-requests"
tail -F ~/.ucode/routing-requests.jsonl   # then start a new smart-routed ug session

Revert with uv tool install --force --python 3.12 git+https://github.com/databricks/unity-gateway. The --python 3.12 pin avoids a hatchling build failure when uv picks an older default interpreter.

Testing

  • New test_routing_request_is_logged: the logged URL and body equal what was sent, and the token is absent.
  • Routing suites (test_claude_routing, test_codex_routing, test_*_smart_routing_v2): 132 passed. ruff check and ruff format --check clean.
  • Full suite: 4316 passed; 4 test_skills.py::test_orchestrator_injects_the_installed_agent_instructions cases fail identically on unmodified main in this environment.

This pull request and its description were written by Isaac.

…s.jsonl

Debug aid for inspecting the exact route menu ug sends to the AI Gateway
router. select_route is the single call site for the Claude first prompt,
Claude subagent, and Codex menus, so each call appends one JSON line with
the URL and request body. The bearer token is not recorded. Output goes to
a file because stdout belongs to the TUI and the hook protocol.

Co-authored-by: Isaac <no-reply@databricks.com>
@xsh310
xsh310 force-pushed the debug-log-routing-requests branch from 3cb7f50 to 84c6636 Compare October 18, 2026 03:00
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