Skip to content

feat(config): run cache_aware_summarizer in medium (pre_expiry) and high (any) - #456

Merged
amiddavid merged 2 commits into
mainfrom
feat/preset-ladder
Oct 11, 2026
Merged

amiddavid merged 2 commits into
mainfrom
feat/preset-ladder

Conversation

@amiddavid

@amiddavid amiddavid commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

From medium up, the preset picker now uses cache_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

Preset Summarizer today (with #414) With this PR
conservative none none
medium none cache_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.
high summarize cache_aware_summarizer, cache_state: any: the summary is made at 90% of the window and used on the next request.
xhigh cache_aware_summarizer, any unchanged: high plus extract_llm_sweep

summarize is no longer in any picker tier. It stays available by name for the cases where it is the better choice.

Why pre_expiry fits medium

  1. It never changes the history while the user works.
  2. It acts only when the alternative is expensive. On Sonnet 5 at 900k tokens, a cold return without a summary re-writes about 900k ($2.25). With the reserve it writes about 80k ($0.20).
  3. Preparing the reserve costs about $0.02 extra: the summary call takes the place of a ping that is sent anyway.

Limits

  • medium needs keep-alive to prepare a summary. With cache strategy none, its summarizer almost never acts.
  • The reserve is used only after the keep-alive pings stop and the user returns after the cache expired. The cache strategy, not the preset, decides how long the cache stays warm.

What changed

  • config/config.go: the medium and high presets, and the ladder comment.
  • User-facing text: plugin.json, settings.py, README.md, the preset-picker and insights-components skills, insights.py, and docs/reference/presets.md.

How it was tested (eval box, CGO_ENABLED=1)

Test Result
TestPresetLadderSummarizerModes: medium pins pre_expiry; high and xhigh use the default; no tier runs summarize; each preset builds pass; fails on #414's config
TestHighPresetCommitsACacheAwareSummary (through serve()) 1 summary call; 0 on #414's high
TestMediumPresetDoesNotSummarizeOnAWarmTurn (through serve()) 0 calls on warm turns
TestPresetDocsDoNotDrift, TestPluginPresetPipelinesAgreeWithConfig, TestEveryPresetOfferedIsOneInsightsCanExplain pass
go test -race ./config/... ./components/offload/... pass

Open questions

…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 amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_used is 5 while calls is 0. That counter counts prepared commissions, not paid calls, so this is correct.
  • Not run live: the medium reserve 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

  1. TestMediumPresetDoesNotSummarizeOnAWarmTurn does not test the shipped medium preset. It passes when medium has no summarizer at all.
    • The test gives its own cache_aware_summarizer block, which includes cache_state: pre_expiry. applyPreset replaces the preset's block with that block as a whole (merged[k] = v). So the preset's pre_expiry never gets to the test.
    • Mutation 1: I removed cache_state: pre_expiry from the medium preset. This test still passes. (TestPresetLadderSummarizerModes fails, as it should.)
    • Mutation 2: I removed cache_aware_summarizer from the medium pipeline, which gives the #414 medium. This test still passes. The test only checks that nothing happened, and "no summarizer" gives that result too.
    • Proposal: remove cache_state: pre_expiry from the test's override, so the preset supplies it. Also add a positive check that the summarizer ran and stopped at the cache_state gate, for example a non-zero cache_aware_summarizer_prefix_ask_used (5 in the live run) or the gate name in the report. Then the test fails if medium loses either the summarizer or pre_expiry.
    • Smaller: TestHighPresetCommitsACacheAwareSummary (and the xhigh test from #414) also re-specify model.source: incoming, so they do not check the preset's value. TestPresetLadderSummarizerModes checks it, so this one is non-blocking.

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 default keep_last is 3, in messages) and the "(#413)" credit for the swap. Good.
  • Data use: medium and high now depend on the in-memory store of the last forwarded body (sentStash). proxy.go:1663 fills that store on every request, whatever the preset is or whether --store is 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]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Finding 1 fixed in f5198c0

Result: the preset tests now check the presets' own cache_aware_summarizer settings. Both of your mutations fail the medium test.

What changed

  1. New test helper presetWithLowTrigger. It loads the preset, keeps the preset's own cache_aware_summarizer block (model.source, cache_state), and lowers only the trigger. The medium, high and xhigh tests use it.
  2. TestMediumPresetDoesNotSummarizeOnAWarmTurn also has a positive check: cache_aware_summarizer_prefix_ask_used must go up, so the summarizer ran and stopped at the cache_state gate.

Your mutations, re-run (eval box)

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
amiddavid changed the base branch from feat/xhigh-cache-aware to main October 11, 2026 14:44

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -race of 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: …" and TestCacheAwarePipelineOrderMinimalTextCleanCase. So that comment is now the start of the doc comment of presetWithLowTrigger. Move the helper above the comment, or move the comment down.

@amiddavid
amiddavid merged commit 74df042 into main Oct 11, 2026
5 of 6 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Oct 11, 2026
@amiddavid
amiddavid deleted the feat/preset-ladder branch October 11, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

presets: use cache_aware_summarizer in medium (pre_expiry) and high (any)

1 participant