Problem
When a new session starts, the context usage bar shows 0/200K (0%) and stays at 0 until the first LLM response comes back with stream.usage data.
Root cause
-
ContextMonitor initializes lastRealInputTokens = 0 (Java long default) — no mechanism exists to set an initial value at session start.
-
onUsageUpdate is only triggered by StreamingAgentLoop after receiving a streaming response with accumulator.usage — before any LLM call completes, the CLI has no input token data.
-
Anthropic's API only reports input_tokens in the response (message_start and message_delta SSE events), so the CLI cannot know context occupation before the first request is sent and a response begins streaming.
Current behavior
| Time |
ctx display |
Reason |
| Session start |
0 |
ContextMonitor default, daemon sends no initial usage |
| After user input, before LLM response |
0 |
Input tokens come from API response |
| During LLM streaming |
Real value |
message_delta → stream.usage → recordStreamingUsage |
Additional issue: debug log messages leaking to console
logback-cli.xml had ContextMonitor set to DEBUG level, causing recordStreamingUsage and recordTurnComplete debug messages to appear on the user's terminal.
Linked
Part of Epic #248
Problem
When a new session starts, the context usage bar shows
0/200K (0%)and stays at 0 until the first LLM response comes back withstream.usagedata.Root cause
ContextMonitorinitializeslastRealInputTokens = 0(Java long default) — no mechanism exists to set an initial value at session start.onUsageUpdateis only triggered byStreamingAgentLoopafter receiving a streaming response withaccumulator.usage— before any LLM call completes, the CLI has no input token data.Anthropic's API only reports input_tokens in the response (
message_startandmessage_deltaSSE events), so the CLI cannot know context occupation before the first request is sent and a response begins streaming.Current behavior
message_delta→stream.usage→recordStreamingUsageAdditional issue: debug log messages leaking to console
logback-cli.xmlhadContextMonitorset toDEBUGlevel, causingrecordStreamingUsageandrecordTurnCompletedebug messages to appear on the user's terminal.Linked
Part of Epic #248