Repository navigation
Fit the model-switch checkpoint into the range it replaces - #1863
Conversation
Bound switch checkpoints by the replaced range with framing headroom, dropping carried messages before clipping the summary. Fall back to a short history pointer so oversized checkpoints do not prevent model switches.
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Fei2411
left a comment
There was a problem hiding this comment.
Code Reaper review (comments only): needs two small fixes before lulu merges.
The fix addresses #1822 correctly for text-only ranges. The 13 tests in model-switch-compaction.test.js and lint pass locally on 5b71abc. CI is green apart from two package jobs still queued. The PR merges cleanly with dev.
1. The budget uses a different count than the one DSH checks (should fix).
In writeCheckpoint, rangeTokens adds up meter.estimateMessage(...) over input.messages. DSH (dsh-compaction-basic summarizeCompaction) does not compare against that. It refuses when framedSummaryTokenCount >= shadowedRouteTokenCount, and that number is the sum of measure(session).nodes[i].tokens over the shadowed seqs. Those are route-priced counts: images are charged the route's visual tokens and files their projected text (priceSurface in dsh-token-meter). They differ from estimateMessage in either direction whenever the range holds images or files, which is common for Bots that use the browser. In that case the switch can still fail with the same error, or the checkpoint gets trimmed more than it needs to be.
canMakeRoom in this file already does it the route-priced way through measured.nodes. The compactRegion wrapper knows start/end, so it could record them next to switchRanges, and writeCheckpoint could sum measureOf(session).nodes between those seqs. Please add a test case with an image block in the range.
2. The PR body has no Agent: line (AGENTS.md).
Add Agent: Devin (Cognition). The repo has no Devin agent/*/model/* labels, so no labels are needed.
Minor (no need to block on it).
The last-resort text 'Earlier context: read_own_chat.' drops the [Checkpoint N] mark. checkpointCount then misses it, and the next checkpoint's number starts again from the earlier count. [Checkpoint N] Earlier context: read_own_chat. would keep the mark and costs only a few tokens.
Overlaps.
Other open PRs that touch ds-bot/src/host/parts.js:
- #1841 (Software Factory), #1771 and #733 merge cleanly with this PR.
- #1745, #1074, #1855, #1817, #1055 and #736 already conflict with
dev, so they don't affect the order.
Nothing has to land before this one.
DSH compares replacement checkpoints against the selected surface nodes' route-priced tokens, not attachment reference estimates. Preserve the explicit boundaries and snapshot those node prices before summarizing so images and files neither permit oversized checkpoints nor discard summaries unnecessarily.
Fei2411
left a comment
There was a problem hiding this comment.
Code Reaper re-review (comments only): ready for lulu.
Both fixes from my last review are in c4b60817:
- The switch checkpoint budget now sums the route-priced
measureOf(session).nodes[].tokensover thestart..endseqs that thecompactRegionwrapper records. That is the same numberdsh-compaction-basicchecks against. It is taken before the summary request, like DSH'sprepareCompaction, and it falls back to the heuristic estimate only when no measurement is available. - The
Agent: Devin (Cognition)line is in the PR body. - The last-resort text keeps its
[Checkpoint N]mark when there is room for it.
Checks: model-switch-compaction.test.js passes 17/17 locally, including the new image and file cases. All CI checks pass on c4b60817, and the PR merges cleanly with dev.
Overlaps are unchanged: #1841, #1771 and #733 also touch parts.js and merge cleanly with this PR. Nothing has to land first.
Issue
Fixes #1822
Bug: switching a Bot to a model with a smaller context window (e.g. gpt sol 6.2 → codex/gpt-6.2-astra) failed with
context compaction failed: summary is not smaller than the shadowed content (7210 … >= 6525), and the Bot stayed on the old model with no way out.Agent: Devin (Cognition)
What changed / 改了什么
ds-bot/src/host/parts.jswriteCheckpoint: for a range DSH condenses for a model switch, DS Bot's checkpoint (summary + kept recent messages) could be larger than the range it replaces, so DSH refused the switch. The switch checkpoint is now sized against the replaced range measured the way DSH checks it: the route-priced token counts of the selected nodes (measureOf(session).nodes), so images and files count at the route's price. It drops the oldest kept messages first, then clips the summary, and as a last resort uses a minimal[Checkpoint N]pointer toread_own_chat. Ordinary checkpoints are unchanged.ds-bot/test/model-switch-compaction.test.js: regression tests (oversized carried messages, long/empty summaries, no summary model, small ranges, image/file ranges priced above and below the plain estimate). They fail before the fix, e.g.194 framed tokens must be smaller than 158and647 framed tokens must be smaller than 180 route-priced tokens.Limit: DSH adds ~90 framing tokens even to an empty summary, so a range smaller than that still can't be replaced without a DSH change.
Changelog
Switching a Bot to a model with a smaller context window no longer fails with "summary is not smaller than the shadowed content".
How I checked it / 怎么验证的
npm test(inds-bot/) — 3095 pass, 4 skipped; two timing-sensitive tests unrelated to this change (archive cleanup, gateway subprocess) timed out once and pass on rerunnode scripts/build-client.mjs --checknpm run lintindex.jsorsrc/host/— 52/52 steps passed (DSHdsh-v0.2.2-rc.1)Checklist / 检查
src/client/changed →npm run buildran andclient.jsis committed. / 改了src/client/就已重新 build 并提交client.js。 (no client change)Co-authored-by. / 没有把 AI 工具写成作者或Co-authored-by。Implemented in session Fix Chief switch to smaller-window model
Review with Devin · Open in Devin Desktop