fix(cli): show only the routed model in the footer header

This commit is contained in:
Tin Chi Lo 2026-09-14 23:54:50 -07:00
parent 4fca818f34
commit d0fdf1c237
3 changed files with 9 additions and 13 deletions

View file

@ -580,8 +580,8 @@ What the command changed is recorded in `~/.litellm/claude_configure_state.json`
`lite configure claude`, `lite login --config-claude`, `lite up` and `lite autoroute up` also install a status line (`~/.litellm/statusline.py`, registered as `statusLine` in `~/.claude/settings.json` unless you already run one) that shows which model the auto-router actually served the last turn and, once the proxy has recorded the session, what the session cost against the router's savings baseline:
```
claude-auto · Routed to: claude-haiku-4-5 -63% vs Claude Opus 5
LiteLLM ████████░░░░░░░░░░░░░░░░ $0.14
Routed to: claude-haiku-4-5 -63% vs Claude Opus 5
claude-auto ████████░░░░░░░░░░░░░░░░ $0.14
Claude Opus 5 ████████████████████████ $0.38
```

View file

@ -43,7 +43,6 @@ FETCH_TIMEOUT_SECONDS: Final = 3
BAR_WIDTH: Final = 24
BAR_FULL: Final = "\u2588"
BAR_EMPTY: Final = "\u2591"
SEPARATOR: Final = " \u00b7 "
TRANSCRIPT_SCAN_LIMIT_BYTES: Final = 4 * 1024 * 1024
CLAUDE_BASE_URL_ENV_KEYS: Final = ("ANTHROPIC_BASE_URL",)
CLAUDE_API_KEY_ENV_KEYS: Final = ("ANTHROPIC_AUTH_TOKEN", "ANTHROPIC_API_KEY")
@ -315,11 +314,8 @@ def render(model: str, session: Session | None, config_dir: Path, use_color: boo
return f"{code}{text}{RESET}" if use_color else text
routed: Final = paint(BOLD, f"Routed to: {model}")
if session is None:
if session is None or session.baseline_model is None or session.baseline_spend <= 0:
return routed
header: Final = f"{session.router_name}{SEPARATOR}{routed}"
if session.baseline_model is None or session.baseline_spend <= 0:
return header
reference: Final = baseline_label(session.baseline_model, config_dir)
pct: Final = (session.baseline_spend - session.spend) / session.baseline_spend * 100
delta: Final = paint(LITELLM_COLOR, f"{'-' if pct >= 0 else '+'}{abs(round(pct))}% vs {reference}")
@ -335,7 +331,7 @@ def render(model: str, session: Session | None, config_dir: Path, use_color: boo
f"{paint(DIM, f'${amount:.2f}')}"
for label, amount, color in rows
)
return "\n".join((f"{header} {delta}", *lines))
return "\n".join((f"{routed} {delta}", *lines))
def color_enabled(env: Mapping[str, str]) -> bool:

View file

@ -252,7 +252,7 @@ class TestRender:
def test_savings_header_and_bars_against_the_routers_baseline(self, config_dir):
text = render("claude-sonnet-5", RECORDED, config_dir, use_color=False, bar_width=10)
assert text.splitlines() == [
"claude-auto · Routed to: claude-sonnet-5 -63% vs Claude Opus 5",
"Routed to: claude-sonnet-5 -63% vs Claude Opus 5",
"claude-auto ████░░░░░░ $0.14",
"Claude Opus 5 ██████████ $0.38",
]
@ -330,7 +330,7 @@ class TestRender:
assert "+25% vs Claude Opus 5" in render("m", dearer, config_dir, use_color=False)
def test_without_a_baseline_only_the_routed_line_shows(self, config_dir):
assert render("m", RECORDED._replace(baseline_model=None), config_dir, False) == "claude-auto · Routed to: m"
assert render("m", RECORDED._replace(baseline_model=None), config_dir, False) == "Routed to: m"
assert render("m", None, config_dir, False) == "Routed to: m"
def test_color_wraps_the_same_text(self, config_dir):
@ -352,7 +352,7 @@ class TestClaudeCodeMode:
return Fetched(RECORDED, definitive=True)
text: Final = _run(_payload(transcript), _env(tmp_path, config_dir), fetch)
assert text.startswith("claude-auto · Routed to: claude-sonnet-5 -63% vs Claude Opus 5\n")
assert text.startswith("Routed to: claude-sonnet-5 -63% vs Claude Opus 5\n")
assert text.splitlines()[1].startswith("claude-auto ")
def test_a_discovered_display_name_labels_the_sessions_model(
@ -364,7 +364,7 @@ class TestClaudeCodeMode:
return Fetched(session, definitive=True)
text: Final = _run(_payload(transcript), _env(tmp_path, config_dir), fetch)
assert text.startswith("claude-auto · Routed to: Claude Opus 5 -63% vs Claude Opus 5\n")
assert text.startswith("Routed to: Claude Opus 5 -63% vs Claude Opus 5\n")
def test_an_unrecorded_session_degrades_to_the_routed_line(self, tmp_path, transcript, config_dir):
assert _run(_payload(transcript), _env(tmp_path, config_dir), lambda c, s: Fetched(None, True)) == (
@ -420,7 +420,7 @@ class TestCodexMode:
out = _run({"hook_event_name": "Stop", "session_id": SESSION_ID, "transcript_path": "/nope"}, env, fetch)
message = json.loads(out)["systemMessage"]
assert message.splitlines()[1] == "claude-auto · Routed to: claude-sonnet-5 -63% vs Claude Opus 5"
assert message.splitlines()[1] == "Routed to: claude-sonnet-5 -63% vs Claude Opus 5"
assert message.splitlines()[2].startswith("claude-auto ")
assert message.startswith("\n")
assert seen == [Credentials("http://127.0.0.1:4000", "sk-codex")]