Skip to content

fix(desktop): include completion tokens in context gauge total (#5283)#5467

Merged
SivanCola merged 2 commits into
esengine:main-v2from
ttmouse:fix/context-token-total-5283
Jun 28, 2026
Merged

fix(desktop): include completion tokens in context gauge total (#5283)#5467
SivanCola merged 2 commits into
esengine:main-v2from
ttmouse:fix/context-token-total-5283

Conversation

@ttmouse

@ttmouse ttmouse commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #5283 by making ContextSnapshot() report the current turn total used tokens as promptTokens + completionTokens, so the Desktop context-window gauge and breakdown no longer scale the prompt segment down when completion/reasoning tokens are present.

Changes

  • Update internal/control.Controller.ContextSnapshot() from prompt-only usage to total prompt + completion usage.
  • Add a controller regression test for the reported 6840 prompt + 48 completion/reasoning = 6888 used case.
  • Add a frontend context-panel regression test to ensure prompt tokens are not scaled down for the [Bug]: GUI界面的上下文窗口数值似乎计算小错误 #5283 token breakdown.

Verification

  • go test ./internal/control passed
  • go test ./internal/control ./internal/cli ./internal/serve passed
  • pnpm --dir desktop/frontend exec tsx src/__tests__/context-panel-breakdown.test.ts passed, 19/19
  • git diff --check passed

Scope

  • 3 files changed: internal/control/controller.go, internal/control/controller_test.go, and desktop/frontend/src/__tests__/context-panel-breakdown.test.ts.

Cache Impact

  • No provider request serialization, system prompt, tool schema, memory prefix, or compaction behavior changes.

Cache Guard

  • Not applicable; this PR changes controller/UI telemetry reporting and regression tests only.

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development agent Core agent loop (internal/agent, internal/control) labels Jun 28, 2026
Co-authored-by: SivanCola <32437197+SivanCola@users.noreply.github.com>
@github-actions github-actions Bot added the desktop Wails desktop app (desktop/**) label Jun 28, 2026
@SivanCola SivanCola merged commit 715630d into esengine:main-v2 Jun 28, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: GUI界面的上下文窗口数值似乎计算小错误

2 participants