Repository navigation
feat(plugin): next-request cost on the status line, shared request budget, context bar fix - #653
Merged
Merged
Conversation
…dget, context bar fix
Status line
- New `next` element: what the next request costs for the cached prefix, warm vs cold
(`next $0.03 warm · $0.30 cold`), from /api/cachestate next_warm_usd / next_cold_usd. An older
proxy falls back to rewrite_usd (`next $0.30 if cold`); an unpriced model shows nothing.
- Request budget: cache files move to ${XDG_CACHE_HOME:-~/.cache}/context-guru/ (0700) instead of
a shared /tmp path; cachestate TTL 10 s, stats TTL 30 s; one render per window refreshes
(O_EXCL lock); failures back off exponentially up to 5 min and the last good copy is served.
The logic lives in scripts/cgcache.py.
- `cg.py cachestate --json [--session S]` prints the cached cachestate (plus age_s, stale) and
refreshes it under the same rules, for the mods.
Context bar
- The bar jumped to 100% and dropped back after the next request. /api/cachestate's top-level
model/window/window_exact describe the latest touch on ANY thread, while _main_cs only swapped
in the main thread's model and prefix, so a sub-agent on a smaller-window model made the main
prompt read against its window. The window is now dropped when the main thread is on another
model than the latest touch.
Insights
- `insights tools` lists MCP servers (per-tool rows under each), and skills, with their cost,
never Claude Code's built-in tools. Uses carry_usd when the proxy reports it, else unused_usd.
- savings shows a "Manual pings" row from /api/stats manual_pings once there is one.
Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Osher Elhadad <[email protected]>
amiddavid
added a commit
that referenced
this pull request
Oct 21, 2026
…0.2.3) (#657) chore(plugin): bump the plugins for v0.5.3 (Claude Code 0.5.3, Codex 0.2.3) Both plugins changed in this release, so installed plugins must update. - Claude Code plugin: the band with cache state and a Ping button (#651), next-request cost on the status line and the context bar fix (#653), insights tools leaves out unpriced carry costs (#656), and the xhigh preset list without the sweep (#654). - Codex plugin: the vendored cg.py and cgcache.py from #651, #653 and #656. Assisted-By: Claude Signed-off-by: DAVID AMID <[email protected]>
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.
Implements the status line and insights parts of the plugin feature contract (sections 2, 3, 4, 7, 8, and the Manual pings category of 1/6).
What changed
nextstatus-line element:next $0.03 warm · $0.30 cold, fromnext_warm_usd/next_cold_usd. Once cold it isnext $0.30. A proxy without those fields falls back torewrite_usd(next $0.30 if cold); an unpriced model shows nothing. It is the first element dropped when the line is too narrow.threads[]); the main clock and context bar still follow the main thread.${XDG_CACHE_HOME:-~/.cache}/context-guru/(0700; a directory owned by someone else is never used), not a shared/tmppath. TTLs: cachestate 10 s, stats 30 s. One render per window refreshes (O_EXCLlock); failures back off 1 s, 2 s, 4 s ... 5 min and the last good copy keeps rendering. Logic is inscripts/cgcache.py, vendored into the Codex plugin withcg.py.cg.py cachestate --json [--session S]prints the cached cachestate plusage_sandstale, refreshing under the same rules, for the mods. Exit 1 with{"error": ...}when there is nothing.insights toolsnow opens with MCP servers (per-tool rows under each) and skills with their cost, and never lists Claude Code's built-in tools. It usescarry_usdwhen the proxy reports it and says so when it only hasunused_usd.savingsfrom/api/statsmanual_pings, shown once there is one.Context bar bug (100% then back)
/api/cachestatetop-levelmodel/window/window_exactdescribe the latest cache touch on any thread._main_csreplaced the model and prefix with the main thread's entry but kept the window. When the latest touch was a sub-agent on a smaller-window model (haiku, 200k, exact) and the main thread was sonnet on 1M with a 412k prefix, the bar computed 412k / 200k and read 100% with "rewrite near", until the main thread spoke again. The window is now dropped when the main thread is on a different model from the latest touch, so Claude Code's own size is used. Pinned byTestStatuslineContextBarIgnoresSubagentWindow(failed before the fix).Notes for review
nextappears in the balanced and detailed layouts. The weekly-tip golden at 45 columns drops it.insights tools,insights,wastegoldens and their docs pages changed (the built-inNotebookEditrow is gone from the removal list; the carry list is new).TMPDIRnow share it throughXDG_CACHE_HOME; the stats TTL went from 2 s to 30 s, so one backdate was widened.carry_usd/carry_readson/api/toolswas requested from core-backend; until it lands, the tools section shows the unused cost and labels it as such.Tests
go test ./context-guru-plugin/passes (314 s). New tests: context bar, next cost (4 cases), budget TTL/private dir, back-off,cachestate --json(shared with the status line), manual pings, insights tools.