Repository navigation
feat(config): run cache_aware_summarizer in medium (pre_expiry) and high (any) - #456
Conversation
…igh (any) The picker ladder now uses cache_aware_summarizer from medium up (#417): - medium: cache_state: pre_expiry. The summary is prepared in the background, in place of one keep-alive ping, and kept in reserve. It is used only when the user comes back after the cache expired. - high: cache_state any (the default). The summary is made at 90% of the window and used on the next request. - xhigh: high plus extract_llm_sweep (unchanged from #414). summarize is no longer in any picker tier. It stays available by name. User-facing text updated: plugin.json, settings.py, README, the preset-picker and insights-components skills, insights.py, and docs/reference/presets.md. Tests: - TestPresetLadderSummarizerModes: medium pins pre_expiry; high and xhigh use the default; none runs summarize; each preset builds. - TestHighPresetCommitsACacheAwareSummary: 1 summary call through serve(). It fails on #414's high (summarize): 0 calls. - TestMediumPresetDoesNotSummarizeOnAWarmTurn: 0 calls on warm turns. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
Review round 1: no blocking problems. One test proves less than its name says.
Result: the medium and high changes work on live traffic. high commits summaries, and medium does not summarize on warm turns. The tests pass. TestMediumPresetDoesNotSummarizeOnAWarmTurn also passes when medium has no summarizer at all. See finding 1.
What I ran
On the eval box, at head 637204a, with an unmodified main as the control:
go build ./...,go vet,gofmt -l: clean.go test -race -count=1 ./config/... ./components/offload/...: pass.TestPresetLadderSummarizerModes,TestHighPresetCommitsACacheAwareSummary,TestMediumPresetDoesNotSummarizeOnAWarmTurn,TestXHighPresetCommitsACacheAwareSummary,TestEveryPresetBuilds,TestPresetDocsDoNotDrift,TestPluginPresetPipelinesAgreeWithConfig,TestEveryPresetOfferedIsOneInsightsCanExplain: pass.
Live traffic. I used aws/claude-sonnet-5 through the plain gateway, not Context Guru. Each run sent 7 Claude-Code-shaped turns with ANSI test output, with a lower trigger (keep_last_turns: 4, min_request_frac: 0, min_request_tokens: 1). Keep-alive was off.
| Run | Summarizer | Summary calls | Committed | Tokens saved, last 3 turns |
|---|---|---|---|---|
main, preset: high (control) |
summarize |
5 | 5 | 3200, 3840, 4480 |
This PR, preset: high |
cache_aware_summarizer, any |
3 | 3 | 3200, 3840, 4480 |
This PR, preset: medium |
cache_aware_summarizer, pre_expiry |
0 | 0 | none, as expected |
- On
high, the 3 summary calls read 34,635 cache tokens in total, so they reuse the agent's cache. - On
medium,cache_aware_summarizer_prefix_ask_usedis 5 whilecallsis 0. That counter counts prepared commissions, not paid calls, so this is correct. - Not run live: the
mediumreserve path, where a summary takes the place of a keep-alive ping and is used on a cold return. That needs keep-alive on and a wait past cache expiry. The PR description already lists it as an open item.
Findings
TestMediumPresetDoesNotSummarizeOnAWarmTurndoes not test the shippedmediumpreset. It passes whenmediumhas no summarizer at all.- The test gives its own
cache_aware_summarizerblock, which includescache_state: pre_expiry.applyPresetreplaces the preset's block with that block as a whole (merged[k] = v). So the preset'spre_expirynever gets to the test. - Mutation 1: I removed
cache_state: pre_expiryfrom themediumpreset. This test still passes. (TestPresetLadderSummarizerModesfails, as it should.) - Mutation 2: I removed
cache_aware_summarizerfrom themediumpipeline, which gives the #414medium. This test still passes. The test only checks that nothing happened, and "no summarizer" gives that result too. - Proposal: remove
cache_state: pre_expiryfrom the test's override, so the preset supplies it. Also add a positive check that the summarizer ran and stopped at thecache_stategate, for example a non-zerocache_aware_summarizer_prefix_ask_used(5 in the live run) or the gate name in the report. Then the test fails ifmediumloses either the summarizer orpre_expiry. - Smaller:
TestHighPresetCommitsACacheAwareSummary(and thexhightest from #414) also re-specifymodel.source: incoming, so they do not check the preset's value.TestPresetLadderSummarizerModeschecks it, so this one is non-blocking.
- The test gives its own
Notes
- Merge order: this PR is based on #414's branch. Merge #414 first, then retarget this PR to
main. - This PR rewrites the ladder comment in
config/config.go. That removes two wrong statements from #414: "matching summarize's own keep_last tuning" (the defaultkeep_lastis 3, in messages) and the "(#413)" credit for the swap. Good. - Data use:
mediumandhighnow depend on the in-memory store of the last forwarded body (sentStash).proxy.go:1663fills that store on every request, whatever the preset is or whether--storeis set. So this PR does not change what data the proxy keeps. The live runs used--store false.
The preset tests gave their own cache_aware_summarizer block. A `components:` override replaces the preset's block as a whole, so the tests checked their own settings (PR #456 review, finding 1). - New helper presetWithLowTrigger: it loads the preset, keeps its own cache_aware_summarizer block (model.source, cache_state), and lowers only the trigger. - The medium, high and xhigh tests use it. - TestMediumPresetDoesNotSummarizeOnAWarmTurn also checks that the summarizer reached its model step (prefix_ask_used goes up), so a medium with no summarizer fails it. Both review mutations now fail the medium test: medium without pre_expiry (1 ask call), and medium without the summarizer (it never reached its model step). Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
Finding 1 fixed in
|
| Mutation | TestMediumPresetDoesNotSummarizeOnAWarmTurn |
|---|---|
medium without cache_state: pre_expiry |
fails: 1 ask call |
medium without cache_aware_summarizer in the pipeline |
fails: the summarizer never reached its model step |
| no mutation | passes |
The high and xhigh tests now also take model.source from the preset (your smaller point, and point 1 of the #414 review).
amiddavid
left a comment
There was a problem hiding this comment.
Review round 2: finding 1 is fixed. OK to merge.
Result: the preset tests now check the presets' own settings. Both round-1 mutations now fail the medium test. I found no new blocking problems.
Round-1 findings
| Round-1 finding | Status |
|---|---|
1. TestMediumPresetDoesNotSummarizeOnAWarmTurn passed when medium had no summarizer |
Fixed in f5198c0. Mutations below. |
Smaller: the high and xhigh tests set model.source themselves |
Fixed: presetWithLowTrigger keeps the preset's block. |
What I ran
On the eval box, on a merge of f5198c0 with the current main (bfdc2ba, which includes #414):
go build ./...,go vet,gofmt -l: clean.go test -race -count=1 ./config/... ./components/offload/...: pass.go test -raceof the preset tests in./proxy/and./config/(TestXHighPresetCommitsACacheAwareSummary,TestHighPresetCommitsACacheAwareSummary,TestMediumPresetDoesNotSummarizeOnAWarmTurn,TestCacheAwarePipelineOrderMinimalTextCleanCase,TestPresetLadderSummarizerModes,TestEveryPresetBuilds,TestPresetDocsDoNotDrift): pass.TestPluginPresetPipelinesAgreeWithConfig,TestEveryPresetOfferedIsOneInsightsCanExplain: pass.
Mutations:
| Mutation of the shipped preset | Result |
|---|---|
medium without cache_state: pre_expiry |
fails: "got 1 ask calls, want 0" |
medium without cache_aware_summarizer in the pipeline |
fails: "never reached its model step" |
high without model.source: incoming |
passes. This is correct: incoming is the default (internal/cheapmodel/anthropic.go:60), so the mutation changes nothing. |
Live traffic: I did not run it again. f5198c0 changes only proxy/cache_aware_pipeline_order_integration_test.go, so the round-1 live results still apply: high committed 3 of 3 summaries, and medium made 0 summary calls on warm turns.
I also checked that the counter in the new positive check is safe. CacheAwareSummarizerPrefixAskUsed is a process-wide counter. In ./proxy/, only upstreamtimeout_test.go uses t.Parallel(), and the medium test is not parallel. So no other test can increase the counter while the medium test runs.
Non-blocking
proxy/cache_aware_pipeline_order_integration_test.go:143-144: the new helper is between the comment "The minimal reproduction: …" andTestCacheAwarePipelineOrderMinimalTextCleanCase. So that comment is now the start of the doc comment ofpresetWithLowTrigger. Move the helper above the comment, or move the comment down.
Summary
From
mediumup, the preset picker now usescache_aware_summarizer. Each tier uses it in a different mode. Closes #417.#414 is merged; this PR now targets
main.Today vs. with this PR
conservativemediumcache_aware_summarizer,cache_state: pre_expiry: a summary is prepared in the background, in place of one keep-alive ping, and kept in reserve. It is used only when you come back after the cache expired. The history never changes while you work.highsummarizecache_aware_summarizer,cache_state: any: the summary is made at 90% of the window and used on the next request.xhighcache_aware_summarizer,anyhighplusextract_llm_sweepsummarizeis no longer in any picker tier. It stays available by name for the cases where it is the better choice.Why
pre_expiryfitsmediumLimits
mediumneeds keep-alive to prepare a summary. With cache strategynone, its summarizer almost never acts.What changed
config/config.go: themediumandhighpresets, and the ladder comment.plugin.json,settings.py,README.md, the preset-picker and insights-components skills,insights.py, anddocs/reference/presets.md.How it was tested (eval box,
CGO_ENABLED=1)TestPresetLadderSummarizerModes:mediumpinspre_expiry;highandxhighuse the default; no tier runssummarize; each preset buildsTestHighPresetCommitsACacheAwareSummary(throughserve())highTestMediumPresetDoesNotSummarizeOnAWarmTurn(throughserve())TestPresetDocsDoNotDrift,TestPluginPresetPipelinesAgreeWithConfig,TestEveryPresetOfferedIsOneInsightsCanExplaingo test -race ./config/... ./components/offload/...Open questions
mediumandhighis still to run, before the release, together with the integration check after feat(dash,proxy): record wait cause and wake cause per request (#424 record half) #453.