mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 09:51:22 +00:00
fix: /status shows incorrect context percentage — totalTokens clamped to contextTokens (#15114) (#15133)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: a489669fc7
Co-authored-by: echoVic <16428813+echoVic@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -134,9 +134,10 @@ export function deriveSessionTotalTokens(params: {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const contextTokens = params.contextTokens;
|
||||
if (typeof contextTokens === "number" && Number.isFinite(contextTokens) && contextTokens > 0) {
|
||||
total = Math.min(total, contextTokens);
|
||||
}
|
||||
// NOTE: Do NOT clamp total to contextTokens here. The stored totalTokens
|
||||
// should reflect the actual token count (or best estimate). Clamping causes
|
||||
// /status to display contextTokens/contextTokens (100%) when the accumulated
|
||||
// input exceeds the context window, hiding the real usage. The display layer
|
||||
// (formatTokens in status.ts) already caps the percentage at 999%.
|
||||
return total;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user