Repository navigation
Compact Responses within the sliding window in one summary - #1485
Conversation
Server compaction reached past the sliding window and worked through archived history in serial batches, so enabling it on an established conversation could turn the next request into a multi-million-token job. The pilot failed on exactly that. Each request now uses the sliding window's own boundary. Source outside it stays stored but is never replayed or summarized. One helper request summarizes the older active context, narrowing from the old end when it cannot fit, and a checkpoint records where the active window starts so a freed budget cannot walk back into the archive. The windowed prompt fits, so a failed or stalled helper falls back to it and the Response still answers. Continuum's proxy refuses content past 4,000,000 bytes as an HTTP 500, whatever the model's window. Helpers measure their request instead of sending one it would refuse. That exact refusal now reads as an input-size rejection: it can start reactive compaction and no longer counts against route health. Closes #1459 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| archive( | ||
| 0..current.saturating_sub(ACTIVE_WINDOW_ROWS), | ||
| &mut result.archived, | ||
| ); |
There was a problem hiding this comment.
[P2] Keep tool exchanges intact at the 1,000-row cutoff
This archives individual rows before atomic grouping. If a stored tool call falls immediately before the cutoff and its matching tool result immediately after it, the result stays visible while its call is discarded. When the remaining window fits the token budget, the early return at lines 296–297 preserves that split. The context builder considers the pair matched using the full metadata, and final projection does not repair it, so the provider receives an orphan role: tool message and can reject an otherwise valid conversation.
I reproduced this on 18f765d2 with an isolated unit test: 1,002 historical rows, the call at index 1 and result at index 2, followed by the current user input. With a 100,000-token budget, ActiveContext::select archives the call but project emits the result. The assertion that every emitted result retains its call fails.
Please advance the row cutoff past the complete crossing exchange and add a regression test for a pair straddling this boundary. The existing tool-boundary test covers the token-budget cut, but not the 1,000-row cut.
There was a problem hiding this comment.
Re-reviewed the fix in 69ef8e0e: this looks good and resolves the finding. The row cutoff now falls between whole window units, preserving tool call/result pairs, reasoning/answer pairs, and pending exchanges around the current input. The three added regression tests cover these cases.
I reran the focused compaction suite through the pinned CI shell with cargo test --locked --all-features compaction and RUSTFLAGS="-D warnings": 160 passed, 0 failed, 21 ignored. The ignored tests require a disposable migrated PostgreSQL database and were not run in this rereview. No new findings in the focused rereview.
The 1,000-row cut ran on raw rows before grouping, so it could land inside a tool exchange or between a reasoning row and its answer. A split exchange sent a tool result without its call, and a split reasoning group produced a checkpoint that failed validation after the helper had been paid for. Cut between window units instead. A unit that crosses the limit leaves whole, so the window can drop slightly more than the sliding window would but never shows more. A pending exchange around the current input stays whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #1459.
Server compaction reached past the sliding window and worked through archived history in serial batches, so turning it on for an established conversation could make the next request a multi-million-token job. That is what failed in the Nov 4 pilot. This puts compaction back on the Pi model: summarize the older part of what the model can already see, once, and keep a recent tail.
What changed
CheckpointPayload.active_startrecords where the active window starts, because a freed budget would otherwise walk a recomputed window back into the archive. It must be a covered key, so deleting it invalidates the checkpoint rather than leaving it dangling. Older payloads decode unchanged.responses.compaction.helper_timingseparates stream open, first chunk, first visible text and last chunk from total preparation, including for a helper dropped by cancellation.docs/development-contracts.mdnow states the context-scope contract.Continuum's size limit
Real-provider testing found that Continuum's proxy refuses content past 4,000,000 bytes as an HTTP 500, whatever the model's window says, because its shard key cannot grow further. Every Maple request carries the
cache_saltthat triggers this.inference/health.rs. Previously three in 60 seconds opened the route's circuit for 30 seconds for everyone.The legacy path has the same limit and is otherwise unchanged. With the flag off, a GLM Flash conversation that fills its window still fails; that needs its own fix.
Validation
On
69ef8e0e, on current master: pre-commit gates, theos-rustlane with 1,133 tests passing and 57 opt-in ignored (run on the same code just before commit), and the disposable DB suite with 54 tests passing and none skipped. That includes all 21 compaction persistence tests.The runtime evidence below predates the rebase, which merged cleanly, and the row-cut fix in
69ef8e0e. That fix has unit coverage only, because a runtime check needs a conversation over 1,000 rows. It used the encrypted SDK client against a Local stack, with synthetic conversations seeded through the legacy path to reproduce a first enablement.Each was one helper call. All three then recalled facts held only in the summary, said they did not know a fact from an archived turn, answered from the retained tail, and reused the checkpoint with no helper call.
Against a controllable upstream:
context_management: []returned a typedmessage_exceeds_context_limitwith no helper.Not covered, and open decisions
No flag, rollout or deployment change. Rolling back is unchanged: turning the flag off returns to the legacy path.
🤖 Generated with Claude Code