Skip to content

fix(status): avoid misleading context usage when totalTokensFresh=false#626

Open
BingqingLyu wants to merge 2 commits intomainfrom
fork-pr-45270-fix-status-totalTokensFresh
Open

fix(status): avoid misleading context usage when totalTokensFresh=false#626
BingqingLyu wants to merge 2 commits intomainfrom
fork-pr-45270-fix-status-totalTokensFresh

Conversation

@BingqingLyu
Copy link
Copy Markdown
Owner

@BingqingLyu BingqingLyu commented Apr 27, 2026

Summary

Fix status context rendering when session token totals are stale.

When totalTokensFresh=false, status previously fell back to inputTokens + outputTokens, which can overstate context usage and report misleading values like 299k/200k (149%).

This change avoids that fallback for stale totals and reports unknown context occupancy unless fresh totals (or transcript usage) are available.

Changes

  • src/auto-reply/status.ts
    • Stop inferring totalTokens from input+output when totalTokensFresh is explicitly false.
    • Preserve transcript-usage override behavior so runtime can still show a concrete usage value when available.
  • src/auto-reply/status.test.ts
    • Add regression test covering totalTokensFresh=false to ensure status shows unknown context usage instead of synthetic input+output usage.

User impact

  • Prevents false alarms that auto-compaction is broken.
  • Makes /status context line semantically accurate in stale-token states.

Validation

  • pnpm vitest run src/auto-reply/status.test.ts
  • Result: all tests passed locally.

Notes

This is a display/accounting correctness fix; it does not alter compaction trigger behavior itself.

Fixes openclaw#45268

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

status: context usage is misleading when totalTokensFresh=false

1 participant