mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
The "Default" model in NewSession sends no --model flag, so Claude CLI picks its own default (e.g. Opus 4.7 [1m] on Pro accounts). The web status bar then falls back to 200K - 10K headroom = 190K because the Claude SDK path never plumbs the real per-model contextWindow through to the wire-level `modelContextWindow`, unlike the ACP/Codex backends. Fix the gap in three places: - cli/src/claude/sdk/types.ts: declare optional `modelUsage` on SDKResultMessage to surface what Claude CLI already emits (`modelUsage[<model>].contextWindow`). - cli/src/claude/utils/sdkToLogConverter.ts: on system.init, capture the resolved model name (full form with `[1m]` suffix) and derive an initial contextWindow from the suffix. On every assistant message, inject the cached contextWindow into `usage.context_window` when absent. On result, refine the cache with the authoritative value from `modelUsage`. - web/src/chat/normalizeAgent.ts: forward `context_window` through the assistant usage normalization, so the existing reducer path (reducer.ts:175 → StatusBar.tsx:175) can render the real window. Closes #719.