← Back to PRs

#15126: fix(status): avoid false 100% context usage when totals mirror context

by AlexAnys open 2026-02-13 02:27 View on GitHub →
stale size: XS
## Summary Fixes #15114. `/status` could report a misleading `100%` context usage when `contextUsageInput` and `totalInput` had the same numeric value, even if model/provider usage data indicated the real context window utilization should be much lower. This patch makes context-percentage selection stricter: - Prefer provider/model-reported `contextWindow` usage when available. - Only fall back to `contextUsageInput / totalInput` when there is no stronger context-window denominator. - Avoid the false `100%` path when totals merely mirror context counters. ## Changes - `src/auto-reply/status.ts` - tightened denominator/source selection for context usage percentage - `src/auto-reply/status.test.ts` - added/updated coverage for the false-100% scenario ## Validation - ✅ `pnpm check` - ✅ `pnpm vitest run src/auto-reply/status.test.ts` ## AI-assisted - This PR is AI-assisted. - Testing level: targeted local validation completed for impacted scope. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adjusts `/status` context usage reporting to avoid a misleading “100%” when session `totalTokens` mirrors the context window. It adds a guard in `buildStatusMessage` to prefer other usage counters and introduces a regression test for the mirror case. However, `SessionEntry.totalTokens` is stored as last-call context-window utilization, while `inputTokens`/`outputTokens` can be accumulated for cost. Replacing `totalTokens` with `inputTokens+outputTokens` risks inflating the context percentage in real runs where accumulated usage exceeds the context window. <h3>Confidence Score: 2/5</h3> - This PR is not safe to merge as-is due to a logic change that can misreport context usage in common real-world sessions. - The new guard in `buildStatusMessage` can rewrite context-window `totalTokens` from accumulated `inputTokens`/`outputTokens`, contradicting how usage is persisted and causing definite over-reporting (>100%) when accumulated usage exceeds the context window. - src/auto-reply/status.ts <sub>Last reviewed commit: f68d16f</sub> <!-- greptile_other_comments_section --> <sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs