Uh oh!
There was an error while loading. Please reload this page.
fix(tui): derive context gauge fill from cumulative report deltas - #25
Merged
Conversation
odek serve reports contextTokens (usage and done events) cumulative per run — the sum of prompt tokens across all LLM calls — not the live window fill. Treating it as the fill made the header gauge overflow on any long multi-iteration session (e.g. 100% 2.3M/1.0M) while the backend context window was actually within budget. Track the last cumulative report per run and use the delta between consecutive reports as the window fill: that delta is exactly the last request's prompt size, which drops again after odek trims history. The baseline resets on done (each run's cumulative restarts) and on session resume/clear.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The header context-window gauge overflowed on any long multi-iteration session, e.g.:
● 100% 2.3M/1.0M · ∑ ⌂ 2.3Mwhile the backend context window was actually within budget.
Root cause
odek serve reports
contextTokens— on bothusageanddoneevents — cumulative per run: the sum of prompt tokens across all LLM calls (agent.TotalInputTokens()). bodek treated it as the live window fill, so the gauge pinned at 100% once the cumulative total exceeded the model's context window. The∑ ⌂session total was correct all along.Fix
Recover the live window fill client-side as the delta between consecutive cumulative reports — exactly the last request's prompt size, which drops again after odek trims history:
runCtxCumbaseline on the model, updated onusage, consumed and reset ondone(each run's cumulative restarts), and reset on session resume/clearwinCtxTokis now only ever the per-request prompt size, never a cumulative figureinternal/clientandinternal/tui/view.godocumenting the real wire semanticsTests
TestGaugeDerivesFillFromCumulativeDeltasreplaying the reported scenario (cumulative 600k → 1.4M → 2.3M against a 1.0M window): gauge shows 90%, and drops after a trimmake fmt/vet/lint(0 issues) /test(full race suite) all greenKnown limitation: mid-run the fill lags by one request's output tokens (the delta is prompt tokens only); it self-corrects on the next
usageevent. Exact per-request fill on the wire would require an odek-side change.