Repository navigation
fix: report context occupancy state and track guessed budgets (#69) - #110
Merged
Merged
Conversation
winshaurya
force-pushed
the
fix/context-hint-lifecycle
branch
from
September 6, 2026 21:30
ca1e6e9 to
719eeb7
Compare
Contributor
Author
|
Squashed the commits for easier review. |
winshaurya
force-pushed
the
fix/context-hint-lifecycle
branch
2 times, most recently
from
September 7, 2026 02:05
42e2c6b to
48f4862
Compare
- Distinguish unmeasured, compacted, and active context states via Occupancy enum. - Keep unmeasured context empty to preserve shortcut hint line on 80-column terminals. - Display context compacted and context ~N% for guessed budgets on the hint line. - Restore context measurement on session resume when conversation history has tokens on disk. - Measure context on turn failure when requests were sent prior to error. - Update context occupancy budget immediately when model window is adopted. - Use saturating arithmetic for context fullness calculation.
Nine arguments is one past what clippy allows, so `-D warnings` fails the build, and the three added here belong together anyway: a token count without the budget it is against is not a percentage, and a budget without knowing whether anyone advertised it is not one the hint line may state flatly.
…ands Marking a budget as advertised is a question about where the figure came from, not a reason to move it. Reverting to the default whenever the next model reports nothing raises the budget above a cramped window that is still in force, and a budget above the window does not delay compaction, it removes it: every round asks, no round qualifies, and the session runs to exhaustion looking exactly like one with nothing to summarise. What stands is a figure taken for a model no longer in force, which is exactly what `budget_is_guessed` reports, so the hint line marks it rather than stating it flatly.
Adopting a window answers two questions and only one of them is whether the number changed. A model the listing does not describe leaves the budget standing and stops it being one the endpoint advertised, and a model advertising exactly the budget already in force does the reverse, so a marker carried only when the figure moved is wrong in both directions.
The reading is what a person uses to decide whether to compact, and nothing said which of the three things it knows it is saying, so a blank line meant an empty session, a shortened one, or a turn that had not ended yet. The resume half needed a test of its own: what the last request came to is the server's figure and cannot be recomputed here, so a snapshot that dropped it would leave a resumed session no way back to the number but to spend a turn.
bbondy
force-pushed
the
fix/context-hint-lifecycle
branch
from
September 8, 2026 02:06
0fd1cb6 to
2890130
Compare
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 free
to 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.
Closes #69, where the context percentage disappears or leaves ambiguous states on the hint line.
Changes Made
Please let me know if anything further is needed or if you would like any adjustments. Thank you for your time and review!
The one part of #69 not answered here is the empty case: a session that has measured nothing still draws as a blank. That is #113.