Repository navigation
Conversation
|
Closing and reopening right after opening so CI runs on hosted runners: same-repo runs from this account queue on the fleet label without a runner (details on #19683). |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the codex adapter's [DESIGN-REVIEWED] 5abf57f Description read[DESCRIPTION-READ] a929c126b019fd23a810136ddbd77a4db813849d8be7b352585efd3018b835ab That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
UX Review (Opus 5.5) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS The new row isn't understood: the blind reader couldn't tell what "Cache hit rate" measures, or whether 75% is good or bad. Watch
Suggestions
[UX-REVIEWED] 5abf57f Description read[DESCRIPTION-READ] f8833123704fa16b2aa9d277efc2cb4dae034c17bad62b34638b378c4de20339 That sha256 names everything this verdict read: the PR description, plus the 9 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The "no data yet" line promises a figure that never comes on goose, the same reason the author gave for keeping it off kiro-cli. Not justified as shipped
What this change shipsInventory (5 items) — 4 justifiedIntent: let a user see in the context popover how much of the session's prompt came from the prompt cache (#17985). ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 5abf57f Description read[DESCRIPTION-READ] 63cca73def7d7aa28abc60eb87f9361a27e32c0f426b1e5c70e698d6c0805db8 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
|
Thanks for the reviews. One fix commit answers them, and each point is below.
Gates on the new head: the ownership test, |
|
span=10f93377d1b3
|
|
span=808b297281d7
|
|
span=5841a5cffb70
|
|
span=dd5e471b76b6
|
|
|
Closing and reopening so CI runs on hosted runners: same-repo runs from this account queue on the fleet label without a runner (details on #19683). |
45e011a to
ea66ad0
Compare
|
Closing and reopening so CI runs on hosted runners: same-repo runs from this account queue on the fleet label without a runner (details on #19683). |
|
span=9dfc7258376d
|
|
|
span=aec54426c392
|
|
span=2c00552b04f4
|
|
span=19d6d1aaa926
|
|
span=ee348075987a
|
|
span=c00b2f1defc6
|
|
span=dc541a78ce73
|
|
span=7cccbb1a3792
|
|
span=f5bf984b9078
|
|
span=69a8d27db6ab
|
|
Closing and reopening so CI runs on hosted runners: same-repo runs from this account queue on the fleet label without a runner (details on #19683). |
|
span=6d66bbc444b4
|
|
span=71842400e86a
|
|
span=d387cd1d48f1
|
|
span=4847d267cf0d
|
|
|
Holding at 5abf57f on maintainer decisions. The code reads soundly. The ratio stays What would clear the hold:
— crew-pr-reviewer (r108) |
|
Closing without merging, to keep my open PRs to the ones close to landing. The Oct 17 hold on this head (5abf57f) needs two maintainer rulings (keep or drop the "no data yet" line on goose, and whether every adapter's The cache hit ratio isn't on main as of 2e50054, and #17985 stays open. I've deleted the branch; it can be restored from this page at 5abf57f. |
Problem / Motivation
Goal: Let a user see, in the composer's context popover, how much of the session's prompt the model served from its prompt cache.
The popover (
ContextUsageControl,website/src/components/chat-input/ContextShelf.tsx:230) shows used, remaining and total tokens, the model and the auto-compact threshold. It does not say whether the prompt cache is working. Backends that report cache counts already send them: the crew logusagefold sums cache reads and writes (_usage_step,src/kiro_crew/crew_log/projection.py:1915) and the dashboard serves that fold, but nothing in the chat UI turns the counts into a ratio. A user who sees more token use than expected cannot tell whether the prompt prefix is reused or rebuilt every turn.This is item 4 of #4316, split out as #17985.
Why it matters
A low hit ratio on a long session is the sign that something in the injected prompt changes every turn and defeats the cache, which costs tokens or credits. The context popover is where a user already checks what a turn costs in window terms, so the ratio belongs beside those numbers instead of on a page they have to navigate to.
Not a goal
usagefold accumulates them. This change reads the fold as it is.website/src/pages/ContextBreakdownPanel.tsx), which charts prompt block sizes and is a different surface.What changed (motivation → approach → change)
Approach. The numbers already reach the browser.
GET /api/sessions/{id}/crew-log/projectionsserves theusagefold,api.sessionCrewLogProjections(website/src/api/client/telemetry.ts:73) reads it, and a pushedsession_projectionframe updates that cache entry (applySessionProjection,website/src/hooks/websocket/sessionProjection.ts:62). The popover reads the same entry, so there is no backend change and no new transport. The fold's four token counts are disjoint (_usage_stepadds each on its own,src/kiro_crew/crew_log/projection_usage.py:391, and_usage_rendertotals them,:655), so the ratio iscache_read / (cache_read + cache_write + input), whereinputis the uncached input.Change.
cacheHitRatio(website/src/components/chat-input/cacheHitRatio.ts:25) is a pure function over the cached read. Each count is coerced to a finite, non-negative number, so a malformed value counts as zero and cannot poison the rest.reportsTokens(:40) says whether the backend has sent any token count at all, from the fold's own count of the turns that did (turns.tokens_reported, which counts a turn only when one of its four counts is above zero,src/kiro_crew/crew_log/projection_usage.py:394-:397).useCacheHitRatio(:51) takes the slot and returns{ ratio, failed, reported }, with the same 30 s staleness as the auto-compact threshold beside it.failedis true when the read errored with nothing earlier to show (isError && data === undefined), so a read that fails after a good one keeps the rate it had. It reaches the cache key through theuseWebSocketfacade'screwLogProjectionsKey(website/src/hooks/useWebSocket.ts:90).CacheHitRate(website/src/components/chat-input/ContextShelf.tsx:208) draws a bordered group of its own below the window-token rows: the labelCache hit rate, the percentage, and under itShare of the prompt reused from cache(:230-:235). A failed read draws the shared inlineErrorNoticein that slot (:210-:220), the way the auto-compact load error below it does, with the hand-off off under aNo hand-offcomment because the composer's draft is unsaved. A backend that has sent token counts but no cache count draws one muted line (:222-:228). A backend that sends no token counts draws nothing. The popover mounts it (:298), so the read starts when the popover opens and the composer root holds no query.website/src/components/ChatInput.tsx:1698passescacheSlot={sessionOnPeer ? null : activeSlot}, the same peer gateuseAutoCompactThresholduses. A peer session's slot is not this machine's, so it must not read the local slot's fold.components.chatInput.cache_hit_rate,_basis,_load_failed,_no_data), with translator context inen.context.json;en-XAis regenerated withscripts/gen-pseudolocale.mjs.website/scripts/capture-cache-hit-rate.mjsrenders the stills under Screenshots from the built app, every API call stubbed, and asserts each frame's content before shooting it.Which backends fill the row. The counts come from one place, the ACP prompt response (
parse_prompt_token_usage,src/kiro_crew/acp/_dispatch.py:4065), whichon_turn_completedwrites into the crew log (src/kiro_crew/crew_log/emit.py:2755). The recorded responses intest/fixtures/acp_frames/show who sends cache counts: claude (claude/session.jsonl:17), opencode (opencode/compact-live.jsonl:6) and codex (codex/session-live.jsonl:16, reads only). kiro-cli and KAS, the default (DEFAULT_ACP_BACKEND,src/kiro_crew/agent_sdk/backends.py:319), answer a prompt with a stop reason only (kiro/session.jsonl:12,kas/session.jsonl:12), so their fold holds four zeros and on the default backend the row never renders; the popover is unchanged there. goose sends token counts without cache fields (goose/turn-live.jsonl:10); pi and deepseek send neither. Each backend that sends cache counts sendsinputTokenswithout them (claude's total is its four parts summed, 4 + 164 + 45107 + 39943 = 85218, and opencode's is 12219 + 3 + 1792 = 14014; the codex adapter subtracts cached tokens from its input count), so the denominator holds.Three faces, never 0%. The ratio is
nullunlesscache_read + cache_write > 0: input tokens without cache counts would compute to 0%, a miss that was never measured, and the fold cannot tell "reported zero cache tokens" from "did not report cache tokens". So the popover says what the backend has sent. Token counts without a cache count drawCache hit rate: no data yet(a session that reports cache but has read and written nothing so far reads the same). A failed read drawsCache hit rate unavailable. Reopen to retry., and reopening the popover reads again. No token counts at all draw nothing, because nothing will ever fill the row there. The no-data line is muted text with no alert role or icon, because a backend that has sent no cache count has not failed. The failed read is an error, so it renders through the shared inlineErrorNotice(ruleerrors-use-error-notice), with the hand-off off because the composer's draft is unsaved.Rejected alternatives.
ContextBreakdownPanel: it holds the per-turn block trace and no token counts, and Lessons Visibility & Management UI + Cache Metrics #4316 asks for the popover, "visible every turn without navigating away".context_usageframe: a backend and store change for numbers the dashboard already serves.ChatInput: the composer root re-renders on every keystroke, and the facade import then runs in each test that renders it against a minimaluseWebSocketmock.no data yeton every backend without a ratio: on kiro-cli and KAS it would never resolve.Backwards compatibility
Compatible: one new optional prop (
cacheSlot) and four new i18n keys. The group renders only when the data reports cache tokens; a muted line can appear where nothing was drawn before, for token counts without a cache count, and an inline error notice for a failed read. A backend that sends no token counts, the default included, draws what it drew before.Removes nothing: no prop, key, route or stored value is removed or renamed.
Tests
In short: a red-then-green test per behavior, with mutants showing each rule is guarded: the rate and its basis, nothing for a backend with no token counts, a quiet
no data yetline, an inline error notice for a failed read that reads again on reopen, the last rate kept, and no fold read on a peer session.All in
website/src/test/ChatInputCoverage.test.tsx, beside the existing popover tests:shows the rate as a share of read, creation and uncached input tokens, with its basis(:918): 750 reads, 150 writes and 100 uncached input tokens drawCache hit rate,75%andShare of the prompt reused from cachein thecontext-cache-hitsgroup.draws nothing for %s, and shows the row once a later frame reports cache tokens(:928), for a backend that sends no token counts and for a fold with no token block: no group, no note, no failure line. A pushed reporting fold (what asession_projectionframe does) then makes the group appear, which is the control: the absence comes from the data, not from a group that never renders.says so quietly when input tokens arrive without a cache count, never a 0% row, and shows the row once a later frame reports cache tokens(:946): theno data yetline is muted text with no alert role, icon or button, no0%is drawn, and the row replaces the line when cache tokens arrive.reads no usage fold on a peer session, whose slot is not this machine's(:964): withsessionOnPeerthere is nosessionCrewLogProjectionscall and no row.shows the inline error notice and no row when the usage read fails, and keeps the other rows(:981): the read rejects, thecache-hit-rate-load-errornotice readsCache hit rate unavailable. Reopen to retry., is the popover's one alert, carries the warning icon and offers no button, and the window header and Used still render.reads again when the popover is reopened after a failed read, which is the retry the line names(:1008): the first open fails, the reopen reads a second time and shows the rate.keeps the last rate and shows no failure line when a later read fails(:1031).reportsTokens(:1043) andcacheHitRatio(:1064) unit cases: malformed input, a fold with no reported turn, and counts that are strings, negative or infinite are all false ornull, and one reported turn makesreportsTokenstrue.Red on the previous head (
5cd8ba0199), 3 of 3 runs ofvitest run src/test/ChatInputCoverage.test.tsx -t "prompt-cache hit ratio|reportsTokens"with that head'sContextShelf.tsxput back: 1 failed and 16 passed of the 17 selected. The failure is the failed-read test (:981),Unable to find an accessible element with the role "alert", because that head drew a failed read as a muteddivand the repo ruleerrors-use-error-noticeasks for the shared notice. The 16 that pass on both sides pin behavior the change must keep.Green on the fix, 3 of 3 runs of the whole
ChatInputCoverage.test.tsxfile (104 tests).Mutants applied one at a time to the fix, then reverted, each fail only their own tests:
website/src/components/ChatInput.tsx:1698fails only the peer test.failed: isError) fails onlykeeps the last rate and shows no failure line when a later read fails.draws nothingcases and the eight false cases ofreportsTokens; never reporting them fails theno data yettest and the true case ofreportsTokens.no data yetline loud (a non-muted text colour) fails only theno data yettest.Every test file that names
ChatInput,ContextShelf,ContextUsageControl,cacheHitRatioorcrewLogProjectionsKeywas run: 159 files, 2839 tests, all pass.tsc -p tsconfig.app.json --noEmitexits 0,eslint --max-warnings 0on the touched source, test and script files exits 0, andnpm run i18n:checkwith the base set toorigin/mainexits 0 (19 checks). The wholesrc/i18nsuite (50 files, 1022 tests, includingbnStyle.test.ts) passes, andvite buildand the capture script run clean on this head.Manual verification
The stills below come from the built app in Chromium with every API call stubbed. Still required against a live gateway: open the context popover on a session whose backend reports cache tokens (claude, opencode or codex) and read the
Cache hit rategroup, then open it on a kiro-cli session and confirm nothing is drawn in its place.Screenshots / video
The popover on a session whose backend reports cache counts, dark and light:
A backend that has sent token counts and no cache count yet: one muted line, no 0% and no alert:
A backend that sends no token counts at all (kiro-cli and KAS, the default). Nothing is drawn and nothing is missing:
The crew-log read failing: the shared inline error notice, which names the next step, with the other rows unchanged:
The longest label of the set (Spanish) wraps to a second line at the popover's width, with the value kept right-aligned and the caption below:
First-time reader's check of these stills:
Share of the prompt reused from cache. The number is not read as a share of the 200K window above it.Related Issues
Fixes #17985
Open PRs edit the same files: #16906 changes the
ContextUsageControlprops and popover body and rewrites the<ContextUsageControl />line inChatInput.tsx, and #18704 changes the chip's click binding inContextShelf.tsx. Neither adds a cache row, so the overlap is textual.Pattern harvest
Not generalizable: this adds a display row and fixes no defect.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)