Skip to content

Keep Auto's model while the prompt cache is warm - #183

Merged
BunsDev merged 6 commits into
mainfrom
sticky-hold
Oct 12, 2026
Merged

BunsDev merged 6 commits into
mainfrom
sticky-hold

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Why

Part 2 of sticky Auto routing
(plan), on top of the per-turn cache
measurement from #180. Auto used to pick a model from scratch on every turn. On a long thread a
model switch re-reads the whole history without the prompt cache and drops the previous model's
thinking, so a "cheaper" model was often the more expensive turn (on a 150k-token Opus 5.5
thread: $0.03 to stay warm vs $0.60 to move to Sonnet 5.5 cold, at list prices).

What changes

A new final step in decide() (pure; the router passes lastTurn and the idle time):

  • Free choice on a thread's first turn, after 60 min idle (Claude Code writes 1-hour cache
    entries), when the last turn left under 20k tokens of context, and when the user picked another
    model since the last turn.
  • While warm, Auto never moves down a tier or sideways; it moves up only to a model two or
    more tiers higher, or when Jev is ≥ 0.85 sure the request needs deep reasoning and the
    request does not lean on earlier turns (depends_on_prior_turns < 0.7, a judgment Jev already
    answered but the policy never used).
  • A kept model keeps its effort and fast mode. On the same model, effort adapts freely: the probe
    below shows an effort change keeps the cache on both CLIs. Fast mode is held on the same model
    because neither CLI's fast mode could be measured.
  • Limits win: a model over the premium budget or no longer listed is not held, and a held
    effort is still clamped by the ceiling.
  • Receipts read "Auto kept" with the cache size and idle time; routing records gain warmth and
    held. Callers that pass no cache information (all existing policy tests) behave as before.

Probe (2026-10-12, claude 2.1.296, codex-cli 0.162.1)

CLI same settings effort only model fast
Claude (opus → sonnet) warm after the first resume kept (36,905 of 36,972 read) rebuilt (10,584 read, 26,734 written) not measurable: --settings {"fastMode":true} reported speed: standard
Codex (gpt-6.1-sol → gpt-6-astra) 53,760 of 53,950 read kept (53,760 read) rebuilt (8,960 of 64,082 read) default model has no fast tier

Verification

  • npm run build && npm test: 867 tests, 854 passed, 13 skipped (Windows-only), 0 failed.
  • npm run test:e2e -w @modex/desktop: 241 passed, 3 skipped (real OpenKnowledge cases, environment-gated), 1 failed: panel-resize.spec.ts:98 (a 40 px drag measured 23 px under host load; 18 s vs 3.2 s normal). It touches no code in this PR and passed 3 of 3 on rerun against the same build. The new held-receipt e2e case passed.
  • The pushed tree is identical to the verified tree (rebase onto Measure prompt-cache usage per turn #180's squash, which matched its tested branch).
  • Test stabilization (workspace-store.spec.ts): the Store browser test clicked the New tab
    menu right after opening Settings. A menu event that lands before the Settings render commits
    still sees an unsuspended workspace and opens a tab. It failed this way on the hosted push runs
    of both Measure prompt-cache usage per turn #180 and this PR, and reproduced 3/3 locally by firing both clicks together. The test
    now waits for the Settings dialog first; assertions and timeouts are unchanged; 3/3 passed.

Coven-Harness: Claude Code / claude-opus-5-5
Coven-Harness: Claude Code / claude-opus-5-5
Coven-Harness: Claude Code / claude-opus-5-5
Coven-Harness: Claude Code / claude-opus-5-5
Coven-Harness: Claude Code / claude-opus-5-5
@vercel

vercel Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
modex Ready Ready Preview Oct 12, 2026 8:21am UTC

Request Review

The Store browser test clicked New tab right after opening Settings. A menu event that lands before the Settings render commits still sees an unsuspended workspace and opens a tab (reproduced 3/3 by firing both together; failed twice on hosted push runs). Waiting for the dialog tests the intended state; assertions and timeouts are unchanged.

Coven-Harness: Claude Code / claude-opus-5-5

This branch was successfully deployed

1 active deployment
Preview — 972c5422 Deployed Oct 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant