Repository navigation
fix(telemetry): gate the prompt cache like the model report, and keep the first 20 miss causes - #623
Open
JDProfresh wants to merge 2 commits into
Open
JDProfresh wants to merge 2 commits into
JDProfresh wants to merge 2 commits into
Conversation
… reports it The status-telemetry route gated the model report on capabilities.statusLineTelemetry but stored the prompt-cache report for any session mode, even though both ride the same statusline payload the exporter POSTs. Gate the prompt-cache store on the same capability so a CLI with no statusline exporter no longer carries prompt-cache state it never actually reported.
… post last_miss_cause.causes was z.array(z.unknown()).max(20), so a statusline payload carrying more than 20 causes failed validation and lost the whole post: plan usage, model, cache and the footer with it. Truncate to the first 20 with a preprocess that slices before the array validates, so an over-long array costs one bounded slice rather than per-element work across every entry.
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.
These are the two small follow-ups you flagged on #607, one commit each:
promptCachewas stored for any session mode even though the model report from the same payload is capability-gated, and more than 20 miss causes 400'd the whole statusline post instead of truncating the list.Store the prompt cache only for CLIs whose statusline reports it
POST /api/status-telemetrygated the model report (noteReportedModel) oncapabilities.statusLineTelemetrybut storedpromptCacheunconditionally. Theprompt_cacheobject rides the exact same statusline payload the exporter POSTs, so it is the same question: does this CLI's statusline speak for it. I reusedstatusLineTelemetry(the capability that also decides whether the exporter is injected at all) rather than add a new field, resolved once per request into a local and applied to both the model report and the prompt-cache store. No CLI-id branch. A non-capable session (codex) now stores no prompt cache; the rest of the post (plan usage) still lands.Keep the first 20 miss causes instead of refusing the post
last_miss_cause.causeswasz.array(z.unknown()).max(20), so an over-long array failed validation and lost the entire post: the footer text the route answers with, plan usage, the model report and the cache readout. I replaced the.max(20)with az.preprocessthat slices the array to 20 before the array schema validates, so an over-long array costs one bounded slice rather than per-element validation across every entry, and the element bound (z.unknown()) stays intact on the 20 kept.parsePromptCachealready keeps the string ones among those.Tests
prompt_cachestores nothing on the session and still broadcasts plan usage.Removed each guard and watched its test go red, then restored.
Verified
On this branch, off today's master (1.41.1,
a8a8bb71):npm testgate passes: 11,260 passed, 12 skipped, 0 failed.typecheck,lint,format:check,check:frontend-syntax,check:browser-excludesand prettier on the touched test pass.prompt_cachecarrying 25 miss causes: both answered 200 with the footer text, the claude session stored the cache with the first 20 causes in order, and the codex session stored neither the cache nor a model. On master that post is a 400 for both.