fix: review cost/token tracking for non-streaming API fallback after v2.1.77 fix #232

Closed
opened 2026-03-20 08:26:30 -07:00 by hikari · 0 comments
Owner

Background

CLI v2.1.77 fixed a bug where cost and token usage were not tracked when the API fell back to non-streaming mode. CLI v2.1.79 further improved the non-streaming fallback path with a 2-minute per-attempt timeout to prevent sessions from hanging indefinitely.

Why It Matters for Hikari Desktop

Hikari Desktop independently tracks cost and token usage from the stream-JSON messages (assistant message usage fields and the final result message usage field). If the CLI was previously not emitting usage events in non-streaming fallback mode, we now need to verify our parser correctly handles whatever format they arrive in post-fix.

Additionally, the new 2-minute per-attempt timeout for non-streaming fallback means we should review our own session watchdog timeout. If a fallback attempt is in progress and Hikari Desktop's stuck-session watchdog fires first, we may incorrectly kill a legitimate slow API response.

We should:

  1. Review the watchdog timeout in wsl_bridge.rs against the new 2-minute-per-attempt fallback timeout
  2. Verify that usage events emitted in non-streaming fallback mode are parsed correctly by our ClaudeMessage deserialisation
  3. Add a test for the non-streaming usage event format if it differs from the streaming format

Acceptance Criteria

  • Watchdog timeout reviewed and adjusted if needed
  • Non-streaming fallback usage events verified to deserialise correctly
  • Tests added for the non-streaming usage event format if it differs

This issue was created with help from Hikari~ 🌸

## Background CLI v2.1.77 fixed a bug where cost and token usage were not tracked when the API fell back to non-streaming mode. CLI v2.1.79 further improved the non-streaming fallback path with a 2-minute per-attempt timeout to prevent sessions from hanging indefinitely. ## Why It Matters for Hikari Desktop Hikari Desktop independently tracks cost and token usage from the stream-JSON messages (`assistant` message `usage` fields and the final `result` message `usage` field). If the CLI was previously not emitting usage events in non-streaming fallback mode, we now need to verify our parser correctly handles whatever format they arrive in post-fix. Additionally, the new 2-minute per-attempt timeout for non-streaming fallback means we should review our own session watchdog timeout. If a fallback attempt is in progress and Hikari Desktop's stuck-session watchdog fires first, we may incorrectly kill a legitimate slow API response. We should: 1. Review the watchdog timeout in `wsl_bridge.rs` against the new 2-minute-per-attempt fallback timeout 2. Verify that usage events emitted in non-streaming fallback mode are parsed correctly by our `ClaudeMessage` deserialisation 3. Add a test for the non-streaming usage event format if it differs from the streaming format ## Acceptance Criteria - [ ] Watchdog timeout reviewed and adjusted if needed - [ ] Non-streaming fallback usage events verified to deserialise correctly - [ ] Tests added for the non-streaming usage event format if it differs ✨ This issue was created with help from Hikari~ 🌸
naomi closed this issue 2026-03-23 14:28:09 -07:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nhcarrigan/hikari-desktop#232