From 4f586d655193662fc3eab11cffaf669487ea08d2 Mon Sep 17 00:00:00 2001 From: iris <2+iris@noreply.localhost> Date: Sat, 29 Aug 2026 19:11:51 -0400 Subject: [PATCH] Attribute the drift to the CLI's ceiling, not to a manual compaction The reasoning on AUTOCOMPACT_WINDOW cited 491,562 tokens as where "the CLI compacted it". That was a manual /compact somebody ran, not the CLI's own trigger, so the comment credited a person's intervention to the automatic behaviour it was arguing about. Caught in review by the session whose transcript it was measured from. Corrected from that transcript's compaction boundaries: the window left to `auto` was 1M, and the one automatic compaction fired at preTokens 1,000,184 with the API context peaking at 999,668. So the drift ceiling is twice what the comment said, and near it a single tool call bills about 100k tokens rather than 49k. The correction strengthens the case, but it also changes what the example is evidence *of*, which is why it was worth fixing rather than just raising the number: what held that session together was the person in it running /compact by hand four times, and the 4.2-million-token request happened at the merely-large contexts left between those. The constant is for the sessions where nobody is doing that. No behaviour change. 68 tests, clippy clean, rustfmt clean. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01VETa8afmpWaYezLCqJhDB8 --- server/src/session/claude.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/server/src/session/claude.rs b/server/src/session/claude.rs index f891ba4..79d89f5 100644 --- a/server/src/session/claude.rs +++ b/server/src/session/claude.rs @@ -179,12 +179,18 @@ const STDERR_LOG: &str = "stderr.log"; /// The context size the CLI compacts at, rather than letting it choose. /// /// Left to `auto` a phone session drifts: these run for hours, nobody -/// closes them, and the transcript carries screenshots. One measured here -/// reached 491,562 tokens before the CLI compacted it, and *every* API -/// call re-reads the whole context -- so at that size a single tool call -/// bills about 49k tokens before it does anything, and one ordinary -/// request ("can you make it so you can rename a session?") cost 4.2 -/// million across its 130 calls. +/// closes them, and the transcript carries screenshots. Measured on one +/// here, the window the CLI chose was 1M and it compacted at the ceiling +/// -- its only automatic compaction fired at 1,000,184 tokens, and the +/// context peaked at 999,668. Every API call re-reads the whole context, +/// so near that ceiling a single tool call bills about 100k tokens +/// before it does anything. +/// +/// What kept that session usable was the person in it running `/compact` +/// by hand, four times. That is the state this constant is really for: +/// even between those manual compactions, at the merely-large contexts +/// they left behind, one ordinary request ("can you make it so you can +/// rename a session?") cost 4.2 million tokens across its 130 calls. /// /// 100k is the smallest window the CLI accepts and roughly the cheapest: /// per-call cost falls with the cap, while the compaction it forces costs