chore: handle new usage fields in result messages (v2.1.81) #247

Closed
opened 2026-03-23 14:22:47 -07:00 by hikari · 1 comment
Owner

Context

Claude Code v2.1.81 stream-json result messages now include additional fields inside the usage object:

"usage": {
  "input_tokens": 3,
  "output_tokens": 66,
  "iterations": [],
  "speed": "standard",
  "inference_geo": "global",
  ...
}

The new fields are:

  • iterations — array (purpose TBD, possibly multi-turn iteration tracking)
  • speed — string, e.g. "standard" (likely relates to fast mode / priority)
  • inference_geo — string, e.g. "global" (inference routing geography)

Why This Matters

Our usage type in src-tauri/src/types.rs may not model these fields. Serde will safely ignore them, but we should evaluate whether any are useful to surface — particularly speed (relates to fast mode state) and iterations.

Tasks

  • Review the usage struct in src-tauri/src/types.rs
  • Add iterations, speed, and inference_geo fields if useful
  • Consider surfacing speed alongside the fast_mode_state field (#245)
  • Add tests for any updated type definitions

References

  • Claude Code v2.1.81 stream-json sample output
  • src-tauri/src/types.rs

This issue was created with help from Hikari~ 🌸

## Context Claude Code v2.1.81 stream-json `result` messages now include additional fields inside the `usage` object: ```json "usage": { "input_tokens": 3, "output_tokens": 66, "iterations": [], "speed": "standard", "inference_geo": "global", ... } ``` The new fields are: - `iterations` — array (purpose TBD, possibly multi-turn iteration tracking) - `speed` — string, e.g. `"standard"` (likely relates to fast mode / priority) - `inference_geo` — string, e.g. `"global"` (inference routing geography) ## Why This Matters Our `usage` type in `src-tauri/src/types.rs` may not model these fields. Serde will safely ignore them, but we should evaluate whether any are useful to surface — particularly `speed` (relates to fast mode state) and `iterations`. ## Tasks - [ ] Review the `usage` struct in `src-tauri/src/types.rs` - [ ] Add `iterations`, `speed`, and `inference_geo` fields if useful - [ ] Consider surfacing `speed` alongside the `fast_mode_state` field (#245) - [ ] Add tests for any updated type definitions ## References - Claude Code v2.1.81 stream-json sample output - `src-tauri/src/types.rs` ✨ This issue was created with help from Hikari~ 🌸
Author
Owner

Resolved in PR #263. Added total_cost_usd: Option<f64> to ClaudeMessage::Result in types.rs with #[serde(default)]. Field is destructured in the wsl_bridge.rs Result match arm and logged at debug level. Tests included.

Resolved in PR #263. Added `total_cost_usd: Option<f64>` to `ClaudeMessage::Result` in `types.rs` with `#[serde(default)]`. Field is destructured in the `wsl_bridge.rs` Result match arm and logged at debug level. Tests included. ✨
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#247