fix(display): preserve localized estimate markers and headroom labels

This commit is contained in:
Teknium
2026-09-07 03:45:46 -07:00
parent 62f64ae5b0
commit 9da8c63b1a
2 changed files with 8 additions and 2 deletions
@@ -77,8 +77,10 @@ def child(out: Path) -> None:
cli.conversation_history = result["messages"]
else:
cli.conversation_history.append({"role": "user", "content": "new unpriced question"})
agent._session_messages = cli.conversation_history
print(f"\n=== {scenario}: CLI /context ===", flush=True)
cli.process_command("/context")
print("CLI status bar:", cli._build_status_bar_text(width=120), flush=True)
usage = _get_usage(agent)
session = {"agent": agent, "history": cli.conversation_history, "history_lock": threading.RLock()}
print("=== TUI/Desktop live /context ===", flush=True)
@@ -89,6 +91,8 @@ def child(out: Path) -> None:
print(asyncio.run(runner._handle_status_command(MessageEvent(text="/status", source=source, message_id="fixture"))), flush=True)
print("=== gateway /context ===", flush=True)
print(asyncio.run(runner._handle_context_command(MessageEvent(text="/context", source=source, message_id="fixture"))), flush=True)
print("=== gateway /usage category block ===", flush=True)
print("\n".join(runner._context_breakdown_lines(agent, source)), flush=True)
results[scenario] = {"breakdown": compute_session_context_breakdown(agent, cli.conversation_history), "usage": usage}
(out / "payloads.json").write_text(json.dumps(results, indent=2))
server.omit_usage = True
+4 -2
View File
@@ -118,6 +118,8 @@ def _context_compressor_lines(agent, ctx, used: int) -> list[str]:
"""/context full view: auto-compression threshold/headroom, compression count + last savings,
and cumulative throughput (labelled as throughput, NOT context size)."""
lines: list[str] = []
from agent.context_breakdown import context_display_source
mark = "~" if context_display_source(ctx) != "provider_usage" else ""
threshold = _n(ctx, "threshold_tokens")
threshold_pct = f"{_n(ctx, 'threshold_percent') * 100:.0f}"
if threshold > 0:
@@ -126,7 +128,7 @@ def _context_compressor_lines(agent, ctx, used: int) -> list[str]:
threshold_pct=threshold_pct))
else:
lines.append(t("gateway.context.threshold", threshold=_fmt(threshold),
threshold_pct=threshold_pct, to_go=_fmt(threshold - used)))
threshold_pct=threshold_pct, to_go=mark + _fmt(threshold - used)))
compressions = _n(ctx, "compression_count")
lines.append(t("gateway.context.compressions", count=compressions))
savings = getattr(ctx, "_last_compression_savings_pct", None) if compressions else None
@@ -501,7 +503,7 @@ class GatewayStatusCommandsMixin:
if label.endswith(f"breakdown_cat_{cat_id}"): # missing key: t() echoes it back
label = str(cat.get("label") or cat_id)
pct = round(tokens / total * 100) if total else 0
out.append(t("gateway.usage.breakdown_line", label=label, count="~" + _fmt(tokens), pct=f"~{pct}"))
out.append(t("gateway.usage.breakdown_line", label=label, count=_fmt(tokens), pct=f"~{pct}"))
return out if len(out) > 1 else []
except Exception:
return []