Skip to content

fix: Route headless Claude prompts before launch under smart routing - #1096

Draft
max-rozen-oss-db wants to merge 1 commit into
max-rozen-oss-db/stack/terminal-benchfrom
max-rozen-oss-db/stack/claude-headless-routing
Draft

max-rozen-oss-db wants to merge 1 commit into
max-rozen-oss-db/stack/terminal-benchfrom
max-rozen-oss-db/stack/claude-headless-routing

Conversation

@max-rozen-oss-db

@max-rozen-oss-db max-rozen-oss-db commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #1074.

With smart routing on, ug claude -- -p lost its prompt on Linux and macOS. ug always launched Claude inside its PTY first-prompt router. In print mode the PTY swallowed the piped prompt, and Claude exited with "Input must be provided either through stdin or as a prompt argument when using --print". Terminal Bench found it: every Claude task failed on Linux with routing on, in run 38002405792.

v2.launch_claude now handles print mode (-p/--print) without the PTY:

  • It takes the prompt from the args after --, the argument right after -p, or piped stdin.
  • It routes that prompt with _route_claude_prompt, pins the model with --model, and launches Claude directly. When ug read stdin, it writes the same bytes to Claude's stdin.
  • Subagent routing stays on. The first-prompt hook and socket aren't installed.
  • An explicit --model or a ug-pinned model skips routing. A router failure prints a warning and launches on Claude's default.

Windows headless launches now get first-prompt routing too, since this path doesn't need the PTY. Interactive launches are unchanged.

Verification

  • New TestV2HeadlessClaude tests cover a stdin prompt, a prompt argument, an explicit --model, and a router failure.
  • just lint passes. The unit suite has the same 13 local failures with and without this change. They need local sockets or network, and CI runs them.
  • Terminal Bench with routing on, run 38016091564: all six jobs pass. Harbor Claude went from 0/14 to 13/14 on ug tasks. The log shows ug's routing notice ("Routed to Medium ...") and Claude running on the pinned routed model.

This pull request and its description were written by the Isaac LLM tool (Claude Code, session 35c1ab71-d945-4de6-97b9-b35d5758edb4).

With first-prompt routing on, ug always ran Claude inside its PTY router.
In print mode the PTY swallowed the piped prompt, so `ug claude -- -p`
exited with "Input must be provided". Print mode now takes the prompt from
the -p argument, the args after --, or stdin, routes it, pins the model,
and launches Claude directly. Subagent routing stays on. This also gives
Windows headless launches first-prompt routing.

Co-authored-by: Isaac <no-reply@databricks.com>
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