Repository navigation
feat(compactionpoint): Bob default and Bob/Codex user settings as C (#963) - #964
Conversation
…as C (#963) Local mode only, read once at start, fail open, same off switch as #955. Bob: model.compressionThreshold (default 0.5 of the window), source client_default when unset. Codex: model_auto_compact_token_limit, no default (the client default depends on a per-model catalog). Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
|
Owner decisions on this PR (David Amid, 2026-11-08, given in the session that started this PR):
Assisted-By: Claude Opus 5.5 |
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | 46b88b0adce7 |
blocking |
Verdict: blocking
Findings
-
internal/compactionpoint/bobcodex.go:47 — Bob's threshold is multiplied by OUR window, but the client multiplies by its own catalog window
- What fails: a Bob request for a model where our window differs from Bob's
ex(model)gets a wrong C. Bob compacts atT x ex(model), andex(model)comes from Bob's gateway catalog, 200,000 when the model is missing (your own verification note, bobcodex.go:29-31).Bob.ResolvecomputesT x our window. Our window for claude-opus-5 and claude-sonnet-5 is 1,000,000 (internal/modelinfo/builtin.go:27-28). If Bob's catalog says 200,000 for that model (or lacks it), the real C is 100,000 but we report 500,000 — too high, the direction this package itself calls dangerous: the summarize trigger fires at 0.9 x 500,000 = 450,000 and never fires, and the episode span over-reports savings. - Proof: proxy.go:856 resolves
windowfrom our modelinfo and passes it tocompactionPointFor, which callsh.opts.BobCompact.Resolve(window)(proxy/compactioncfg.go:158). Nothing checks that our window equals Bob's catalog value, and no doc states that assumption. The PR refuses a Codex default for exactly this divergence ("Our window for the same model differs, 872,000 vs 272,000 for gpt-6-sol"), so the same class of error is accepted for Bob without a guard. - Fix: state and bound the assumption. Either document in agent-compaction.md and the
Bobcomment that C assumes Bob's catalog window equals ours and is wrong (too high) when it does not, or apply the default only when the window is provider-exact and cap Bob's C at the table value for the model. The user-set fraction case has the same exposure.
- What fails: a Bob request for a model where our window differs from Bob's
-
docs/how-to/agent-compaction.md:90 — "a bad value gives the table" is false for Bob
- What fails: a reader who sets
model.compressionThresholdto a non-number (say"high") reads that C falls back to the table. The code gives the client default instead: C = 0.5 x window, sourceclient_default(internal/compactionpoint/bobcodex.go:51-66 — a parse failure leavestatBobDefaultThreshold). The PR's own technical notes say "A bad value gives Bob's default, not the table." - Proof:
TestBobFailsOpen(internal/compactionpoint/bobcodex_test.go:366-379) asserts a bad value givesClientDefault, not the table. The doc line contradicts the code and the test. - Fix: in the "Bob and Codex" intro, split the claim: Codex fails open to the table; Bob fails open to its own 0.5 default.
- What fails: a reader who sets
Non-blocking
isClaudeCodeAgent(proxy/compactioncfg.go:170) has no caller left.compactionPointFornow switches ondash.AgentFordirectly. Delete it or keep a test on it.Point.FromClient(internal/compactionpoint/compactionpoint.go:153) has no production caller. proxy/dashcapture.go:515 and dash/replaycap.go:216 hand-roll the same test on source strings. Use it or drop it.- Codex
Resolvetreatsmodel_post_turn_compact_threshold_percent = 0.0(a TOML float) as "set" and gives the table, while the client treats 0 as off. Safe direction, rare input. A numeric compare instead of!= "0"would fix it. - The Codex 0.9 clamp (bobcodex.go:325-327) uses our window, not the client's catalog window — the same exposure as finding 1, but only for a user-set limit, and the code comment says it is a sanity bound only.
What I checked
- The full diff (17 files) and the code around each change:
internal/compactionpoint(compactionpoint.go, bobcodex.go, both test files),proxy/compactioncfg.gowithreadSmall/short,cmd/context-guru-proxystart-up reads,proxy/dashcapture.gorow storage,dash/replaycap.goanddash/compactepisode.goconsumers. - The
client_defaultsource against every consumer ofconfigured: dashcapture.go:515, replaycap.go:216 and 279, compactepisode.go:1117,Recorded,apply/opts.go,proxy/modes.go,components/component.go. All accept both sources; old rows withconfiguredread as before. dash.AgentFor(dash/event.go:1239-1263): "bob-shell/1.0.3" maps to "bob", "codex_cli_rs/0.160.0" to "codex". The hosted-proxy guard (Tenants != nil) holds for all three clients.- Fail-open paths: unreadable or >4 MiB files, missing home, relative
CODEX_HOME, the off switch, bad numeric values, scope and post-turn guards. All give the table (Bob: the default) — no panic, no request blocked. - Behavior-change rule: the PR names the change at the top (Bob C drops to 0.5 x window, Codex only with a user limit), gives the off switch, and records the owner's approval on 2026-11-08. The data-dependence row is updated with #963.
- Tests: the new tests cover the default, the user value, the caps, fail-open, the UA dispatch and the hosted guard. No live tests were run (not approved); Go is not on this machine.
- The PR body (description only; no reviews or comments read before this post).
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 46b88b0adce7 |
blocking |
Verdict: blocking
Findings
-
internal/compactionpoint/bobcodex.go:47 — Bob's default C uses our window, but Bob acts on its own catalog window, and nothing guards or states the difference.
- What fails: a Bob request for a model where our modelinfo window differs from Bob's
ex(model)gets a wrong C. When our window is larger, C is too high — the dangerous direction by this package's own rule: the summarize trigger (frac x C) fires only after Bob already compacted, and the replay cap and the episode span over-report savings. - Proof:
Bob.Resolvecomputesabs = int(math.Floor(t * float64(window)))from the windowh.resolveWindowgives (proxy.go:1257, our modelinfo). The verified client rule (comment at bobcodex.go:226-231) ispromptTokenCount >= T x ex(model), whereex(model)is "the model's context window from the gateway catalog (max_input_tokens, 200,000 when missing)" — Bob's own backend, reached through the/inference/v1/model/infopassthrough (proxy.go:611-619), not our modelinfo. The PR itself records this exact class of divergence and refuses a Codex default for it: "Our window for the same model differs (872,000 vs 272,000 for gpt-6-sol)". The Bob path has no guard, and theNotesent to the dashboard says "0.5 of the model window" without saying which window or that the two must agree. - Fix: bound the assumption. Either use the client default only when our window is exact, or read
ex(model)from the model/info responses that already pass through the Bob gateway, or at least write the assumption intoPoint.Noteanddocs/how-to/agent-compaction.mdso a reader can tell whether it holds.
- What fails: a Bob request for a model where our modelinfo window differs from Bob's
-
proxy/dashcapture.go:515 — the new
client_defaultrow behavior has no test.- What fails: a regression that stops storing a
client_defaultC on the request row, or stops reading it back in the dash walks, passes every test. - Proof: the #948 equivalent is tested end to end —
TestCompactEndpointRecordsTheConfiguredPoint(proxy/compactioncfg_test.go:126) asserts theconfiguredrow, and the dash walks are tested withCPointSource = "configured"(dash/replaycap_test.go:679, 717). No test anywhere setsclient_defaulton a row: grep finds it only ininternal/compactionpointtests and thecompactionPointFordispatch test. The new arms — dashcapture.go:515,isClientSource(dash/replaycap.go:215),episodeConversationPoint(dash/compactepisode.go:1117) — are untested. - Fix: extend the endpoint test with a
bob-shellUser-Agent row and assertCompactionPointSource == "client_default"; add one dash walk test with aclient_defaultrow.
- What fails: a regression that stops storing a
Non-blocking
isClaudeCodeAgent(proxy/compactioncfg.go:170) has no non-test caller after this PR. Dead code; delete it.agentFromUserAgentmatches"bob"by substring (dash/event.go:1246). Any User-Agent containing "bob" (for examplebobcat/1.0) now gets Bob's default C instead of the table. The Claude Code strings are specific; "bob" and "codex" are short. Consider matchingbob-shell.Point.FromClient(internal/compactionpoint/compactionpoint.go:153) is exported as the one rule for "a row must store this", but the row gate (dashcapture.go:515) and dash'sisClientSourcere-implement it with string comparisons. One rule in three places; a fourth source value needs three edits.
What I checked
- The full diff (17 files) and the code around each change.
internal/compactionpoint:Bob.Resolve,Codex.Resolve,ClientDefault,FromClient,Recorded,Point.Tokens, and the new tests.proxy/compactioncfg.go:ReadBobCompact,ReadCodexCompact,bobSystemSettingsPath, the TOML line scanner, andcompactionPointFor's User-Agent dispatch. Both call sites (proxy.go:856/compact, proxy.go:1259 chat) and the threading throughreqInfo(proxy/modes.go:60, 165) andapply.Opts.- The dash readers of the source string:
replaycap.go(isClientSource,capConversationPoint,walkCapConversation),compactepisode.go(episodeConversationPoint,noteCeiling),event.go,query.go,store.go, and the UI (no consumer keys on the provenance strings;client_defaultrenders raw, like the others). - Fail-open paths: unreadable or odd files, the off switch, hosted mode (
Tenants != nil), unknown window,Scope/PostTurnguards, values above 1 and above 0.9 x window. - Data dependence: the
docs/data-dependence.mdrow is updated, metadata only, decided by David Amid. - The PR description: the behavior change is named at the top, with the owner's approval and the turn-off switch, as CLAUDE.md requires.
- Live tests were not run (not approved). Test claims in the PR body are the author's.
…lient_default (#963) Bob compacts against its own catalog window. Use min(our window, Bob's max_input_tokens from the model/info response), or min(our, 200,000) when not seen. Match Bob by "bobshell/" and Codex by "codex" prefix for the compaction point only. One IsClientSource rule. Codex post-turn 0.0 reads as off. Tests for client_default end to end and in both dash walks. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
Reply to reviewer 1 (round 1). Fixed in c10301e.
|
Reply to reviewer 2 (round 1). Fixed in c10301e.
|
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | c10301ed3d79 |
blocking |
Verdict: blocking
Round-1 findings
- My finding 1 (Bob's threshold times our window): fixed.
Bob.Resolve(window, bobWindow)now usesmin(our window, Bob's window); Bob's window comes from the model/info response the proxy passes through (noteBobModelInfo,forwardBobModelInfo), else Bob's own fallback 200,000. The min rule is right in both directions: a conversation cannot pass the smaller window, so the smaller threshold is the one that acts. A window not seen gives a lower C, the safe side, and the docs say so. The user's fraction follows the same rule. The author's reason for not capping at the table value is right: the table gives 1.0 for opus, which is no cap. - My finding 2 (docs said a bad value gives the table): fixed. agent-compaction.md now splits the claim: Bob fails open to its own 0.5 default, Codex to the table.
- My non-blocking items: all addressed.
isClaudeCodeAgentdeleted. One rule,compactionpoint.IsClientSource, now used by the row writer (dashcapture.go:515) and both dash walks. Codex post-turn is compared as a number, so0.0reads as off. The Codex clamp keeps our window with a comment that says it is a sanity bound only — I accept that reason: the client clamps against its own catalog, which we do not know, and the user's limit is the value the client uses. - Reviewer 1, finding 1 (Bob's window): fixed, same fix, checked myself.
- Reviewer 1, finding 2 (no
client_defaulttest): fixed. Three new tests: the/compactendpoint with abobshell/1.0.3User-Agent assertsclient_defaultand 100,000 (compactioncfg_test.go:171-174);TestReplayCapUsesAClientDefaultCompactionPointandTestEpisodeWalkUsesAClientDefaultCompactionPointcover both dash walks. All helpers they use exist. - Reviewer 1, non-blocking (bob substring, dead code, three copies of the rule): fixed.
clientOfmatches the prefixbobshell/andcodex;bobcat/1.0,my-bob-tool/2andxcodex/1use the table (tested).
Findings
- docs/data-dependence.md:219 — the row does not say the proxy now reads Bob's model/info responses
- What fails: c10301e gives this feature a new input. The local proxy now reads the body of Bob's
GET /inference/v1/model/inforesponses (proxy/proxy.goforwardBobModelInfo, proxy/compactioncfg.gonoteBobModelInfo) and keeps one window number per model id, at most 512 entries, in memory, replaced on each fetch. The row still says the proxy reads "a few short setting values once, at start-up" and lists only config files. A reader of the row cannot tell that the proxy inspects a gateway response body from live traffic. CLAUDE.md makes this row the place that states what a feature reads. - Proof:
git diff 46b88b0a..c10301ed -- docs/touches only agent-compaction.md. The how-to doc documents the read ("keeps one number for each model in memory"); the data-dependence row was not updated. - Fix: add one sentence to the row: for Bob, the proxy also reads the model list that passes through (
/inference/v1/model/info) and keeps one window number per model id in memory, at most 512, replaced on each fetch. Nothing is stored. The per-level claims in the row stay true — this is a doc gap, not a storage change.
- What fails: c10301e gives this feature a new input. The local proxy now reads the body of Bob's
Non-blocking
clientOf(proxy/compactioncfg.go) matches any User-Agent that starts withcodex. A different tool whose UA starts withcodexgets Codex's C when a limit is set. The prefix is deliberate and tested against look-alikes; the exposure needs a user-set limit. Considercodex_if every originator value carries the underscore.- The CodeQL inline (bobcodex.go:162,
abs := int(n)): then > 1<<40guard at line 159 bounds the conversion, and int is 64-bit on the platforms this repo builds. I read the alert as a false positive. A 32-bit build would truncate; none is targeted. forwardBobModelInfotruncates a body over maxRequestBytes (32 MiB) and forwards the truncated bytes with a matching Content-Length. Same pattern as the existingforwardBobProfile, and a model list that size is not realistic. Noted only.
What I checked
- Last review: round 1, 46b88b0, 2026-11-08T18:43:27Z
- New commits read: 1 (c10301e "fix(compactionpoint): bound Bob's window, narrow the UA match, test client_default")
- Read in full: 4 reviews, 3 comments, 2 inline comments (from the three files)
- New items since my last review, and what I did about each:
- Commit c10301e: full diff plus the code around each change —
Bob.Resolve's new window rule and its edge cases (window unknown, Bob window seen or not, model absent from the list),noteBobModelInfo(bounds, lock, wholesale replace),forwardBobModelInfoandisBobModelInfoin the passthrough (hosted guard, Accept-Encoding dropped so the body is readable),clientOf, the Codex post-turn numeric compare, and every new test. - Author's reply to reviewer 1 (19:10:52): each claim checked in the code. All hold.
- Author's reply to reviewer 2 (19:10:54): each claim checked in the code. All hold.
- CodeQL inline at 19:11:58 on bobcodex.go:162: checked, assessed above.
- Reviewer 1's round-1 review (18:45:11, posted after mine): read in full; both findings checked myself, both fixed.
- Owner-decisions comment (18:38:45): read; consistent with the PR body's approval note.
- Commit c10301e: full diff plus the code around each change —
- Concurrency:
bobWinis written underbobWinMuand read under the same lock; parse happens outside the lock. No race seen. - Fail-open: a model/info body that is not the LiteLLM shape records nothing; an unreadable body is streamed unchanged; a model absent from the list keeps the 200,000 fallback, the safe direction.
- Tests were not run by me (not approved; Go is not on this machine). The author's reply reports mutation checks that fail the new tests; those claims are the author's.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | c10301ed3d79 |
blocking |
Verdict: blocking
Round-1 findings
Mine (reviewer 1):
- Bob's default C used our window — fixed.
Bob.Resolve(window, bobWindow)now usesmin(our window, Bob's window); Bob's window comes from the model/info response the proxy passes through (noteBobModelInfo,bobWindow,forwardBobModelInfo), else Bob's own 200,000 fallback. I traced every window combination: ours larger, Bob's larger, Bob not seen, ours unknown, model absent from the list — all give the smaller window or the table, the conservative direction. TheNote, theBobcomment anddocs/how-to/agent-compaction.mdstate the rule. - No test for
client_defaultend to end — fixed. The/compactendpoint test now asserts abobshell/1.0.3row withclient_defaultand 100,000;TestReplayCapUsesAClientDefaultCompactionPointandTestEpisodeWalkUsesAClientDefaultCompactionPointcover both dash walks;TestBobModelInfoPassThroughRecordsWindowcovers the capture. isClaudeCodeAgentdead code — fixed. Deleted;clientOfreplaces it."bob"substring match — fixed.clientOfmatches the prefixbobshell/andcodex;bobcat/1.0,my-bob-tool/2andxcodex/1use the table (tested; I tracedxcodex/1myself: the prefix fails and thedash.AgentForfallback maps only Claude).- One rule in three places — fixed.
compactionpoint.IsClientSourceis the one rule; the row writer and both dash walks call it.
Reviewer 2's:
- Bob's threshold times our window — fixed, same fix. The author rejected the "cap at the table value" alternative because the table gives 1.0 for opus. I checked: the table entry for
claude-opus-5isFrac: 1.00, so the cap would keep C at the window. The reason is right; the min rule is better. - Docs said a bad value gives the table — fixed. The docs now split: Bob gives its own 0.5 default, Codex gives the table.
isClaudeCodeAgentunused — fixed.FromClientunused — mostly fixed.IsClientSourceis the used rule.FromClientitself still has no production caller (non-blocking below).- Codex post-turn
0.0— fixed. Numeric compare;"",0,0.0read as off,0.5,80,abcgive the table (tested). - Codex 0.9 clamp on our window — left as is, comment added. Reviewer 2's own round-1 note called it a sanity bound in the safe direction. Accept.
Findings
- docs/data-dependence.md:219 — the row does not say the feature now reads Bob's model/info responses and holds a model catalog in memory.
- What fails: the row (and the PR's Data dependence section) still say the feature reads a few short setting values once at start-up and holds them in memory. Since c10301e it also reads Bob's live
/inference/v1/model/inforesponse bodies and holds model ids and theirmax_input_tokensin memory (at most 512). An auditor reading the row misses that the proxy inspects Bob's control-plane traffic. - Proof: c10301e adds
noteBobModelInfo,bobWindowandforwardBobModelInfo(proxy/compactioncfg.go, proxy/proxy.go:744) withHandler.bobWinstate filled from response bodies.git diff 46b88b0a..HEAD -- docs/touches onlyagent-compaction.md. The PR's Data dependence section still reads "reads three short values from two config files". CLAUDE.md requires the row update, in plain words, for every PR that changes a feature. - Fix: one sentence in the row (and the PR's Data dependence section): the local proxy also keeps Bob's model ids and their window numbers from the model/info responses that pass through it — in memory, at most 512 entries, never written anywhere; a hosted proxy captures nothing.
- What fails: the row (and the PR's Data dependence section) still say the feature reads a few short setting values once at start-up and holds them in memory. Since c10301e it also reads Bob's live
Non-blocking
- The CodeQL inline (ParseInt to
intat internal/compactionpoint/bobcodex.go:159) is benign on shipped builds:.goreleaser.yamlbuilds amd64 and arm64 only, both 64-bitint, and then > 1<<40bound fits. To close the alert, bound withint64(math.MaxInt). forwardBobModelInfotruncates a model/info body over 32 MiB and forwards the cut bytes with the smaller Content-Length (proxy/proxy.go:748). Same shape as the existingforwardBobProfile, and a model list that large is not realistic. On a read error it also returns false with the body partially consumed — again the existing profile path's shape, and the response is broken anyway.Point.FromClientstill has no production caller;IsClientSourceis the rule everything uses.- The PR's "What changed" bullet still says
compactionPointForpicks the rule bydash.AgentFor; c10301e replaced that withclientOf.
What I checked
- Last review: round 1, 46b88b0, 2026-11-08T18:45:11Z
- New commits read: 1 (c10301e "fix(compactionpoint): bound Bob's window, narrow the UA match, test client_default (#963)")
- Read in full: 3 reviews, 3 comments, 1 inline comment (from
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt) - New items since my last review: commit c10301e (full diff and the code around each change); the author's two reply comments at 19:10 (checked every claim against the code); the updated PR body (behavior-change section carries the new Bob numbers). Older items I read for the first time this round: the owner-decisions comment at 18:38 (all three decisions match the code) and reviewer 2's round-1 review (checked each finding and the author's reply to it, including the rejected "cap at the table" alternative); the CodeQL inline from 17:38 (checked against the release architectures).
- The new code paths:
clientOfprefix matching (tracedbobshell/,codex_cli_rs,xcodex/1,bob-shell/..., Claude Code UAs),Bob.Resolvewindow combinations,noteBobModelInfobounds and locking,forwardBobModelInfofail-open paths (non-200, unreadable body, hosted mode gated off, Accept-Encoding handling), the Codex post-turn numeric compare. - The new tests read in full: bobcodex_test, compactioncfg_test (endpoint, dispatch, bounded map, pass-through), replaycap_test, compactepisode_test.
- Live tests were not run (not approved). Test and mutation claims in the PR body and the reply are the author's.
Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
Reply to both reviewers (round 2). Fixed in b74f1db.Blocking finding (both reviewers): fixed. The Non-blocking: deferred to a follow-up. A code change now would need a new review round.
Full diff diff --git a/docs/data-dependence.md b/docs/data-dependence.md
index 839e2247..4d36adad 100644
--- a/docs/data-dependence.md
+++ b/docs/data-dependence.md
@@ -216,7 +216,7 @@ One row for each registered component. The test `components/all/datadep_test.go`
| Billed-token and cache-time records | metadata | ❌ Gone. `summarize` cannot tell how full the window is. A warm cache can look cold when one conversation comes under two ids. | 🟡 Works, metadata. This record also makes `summarize` start, and so start to waste calls. | 🟡 Works, metadata | To know how full the window is, Context Guru needs the size the provider billed last turn. It also needs the time the cache was last used. The billed size is kept per session and per thread (one integer each). The per-thread one lets `coref` measure how fast one thread grows. |
| **Session state table** (`--session-state`, #769; on with `--dashboard`) | content and metadata | ❌ Off. Dashboard off, `--session-state=false`, or store off: nothing is written. | 🟡 Works, metadata: only the keys of counts, hashes, ids and verdicts are written (`cg:bin:`, `cg:bint:`, `cg:len:`, `cg:ttl:`, `cg:seen:`, `cg:swd:`, `cg:swk:`, `cg:swx:`, `cg:rst:`, `cg:use:`, `cg:tdf:`). Set `--session-state-metadata-only`. The table is in the dashboard database. | ✅ Works. **Also writes the content keys to the dashboard database**: the summary text (`cg:sum:`), `extract_llm` results (`cg:res:`, `cg:xres:`), freeze decisions (`cg:frz:`) and the sweep's held answer (`cg:swh:`). The rewind payloads (the stash) are never written. | A restart, or a pause of more than 2.8 hours, deletes the summary checkpoint and the last billed input from memory. The next turn then sends the full transcript, which can be over the window, and the summary cannot start. A table lets the proxy give a returning session the same state it had. The table is **not encrypted**. It has its own retention, not the dashboard's. A row lives 30 days after its last write. An eviction or an archive can end it earlier, when no other session uses its key. Decided by: David Amid, 2026-10-29 (the dashboard database, on with the dashboard). David Amid confirmed the data-dependence change for `extract_llm_sweep`. Rows to confirm: `cache_aware_summarizer`, `summarize` (Itay Nakash). |
| **Tool deferral history** (`ultrahigh`, #485) | metadata | ❌ Off with no durable place: no dashboard database and tool deferral's own file cannot be opened. Then it lives in memory only, a restart starts it from zero, and nothing is deferred until 3 new sessions. With the Store off nothing is deferred at all. | 🟡 Works, metadata | 🟡 Works, metadata | To defer only the tools a user does not use, it keeps, per user, session and tool: whether the session declared the tool, whether it used or loaded it, the project folder and the time. The rule groups MCP tools by server (`mcp__<server>__*`) when it reads this; the table still holds tool names only. It keeps the newest 64 sessions per user, plus the newest 10 sessions of each project, up to 256 sessions per user in all. The extra sessions are there because the rule checks whether this project used a tool in its last 10 sessions; without them, a user in many projects would push a project's older sessions out, and the check would not see them. It deletes sessions idle longer than the session-state retention (30 days by default). The table is `tool_defer_history`, in the dashboard database when there is one, else in tool deferral's own file. A user's first deferral request copies that user's own sessions, and no other user's, from the dashboard's inventory tables. It also keeps the provider check result per endpoint, model and route (`tool_defer_probe`); that row describes an endpoint, not a user. An account purge deletes the user's history rows, thread records and opt-out flags. Tool names, ids, paths, flags and times only. Nothing is shared between users: the history, the records and the opt-outs are keyed by user, and the pending opt-outs are capped per user. The check spends the user's own credential, under $0.01 per check, once a day per model (a failed check is retried after 15 minutes). Decided by: David Amid, #485, 2026-11-02. |
-| **Client compaction setting** (Claude Code #948; Bob and Codex #963) | metadata | ✅ Works. Nothing is kept: the proxy holds the setting in memory. | 🟡 Works, metadata | 🟡 Works, metadata | The user can move the point where Claude Code compacts its own transcript. The savings figures and the summarize trigger must use that point, or they are wrong for that user. The local proxy reads a few short setting values once, at start-up, from its env and from `settings.json` and `.claude.json` (Claude Code), `~/.bob/settings.json` (Bob) and `config.toml` (Codex), and holds them in memory. For Bob it also uses the client's own default threshold. It writes the resulting C (a number) and its source (`configured` or `client_default`) on each request row (`compaction_point`, `compaction_point_source`). No transcript text, no paths, no other settings. A hosted proxy reads nothing. Decided by: David Amid, #948, #963. |
+| **Client compaction setting** (Claude Code #948; Bob and Codex #963) | metadata | ✅ Works. Nothing is kept: the proxy holds the setting in memory. | 🟡 Works, metadata | 🟡 Works, metadata | The user can move the point where Claude Code compacts its own transcript. The savings figures and the summarize trigger must use that point, or they are wrong for that user. The local proxy reads a few short setting values once, at start-up, from its env and from `settings.json` and `.claude.json` (Claude Code), `~/.bob/settings.json` (Bob) and `config.toml` (Codex), and holds them in memory. For Bob it also uses the client's own default threshold. For Bob, the local proxy also reads the model list that passes through it (`/inference/v1/model/info`). It keeps one window number for each model id, in memory only, at most 512 entries, replaced on each fetch, and never written anywhere. It writes the resulting C (a number) and its source (`configured` or `client_default`) on each request row (`compaction_point`, `compaction_point_source`). No transcript text, no paths, no other settings. A hosted proxy reads and captures nothing. Decided by: David Amid, #948, #963. |
| **Keep-alive pings** | content. The host keeps the credential. | ❌ **Should be off. Today it is still on**, and keeps the last body. The proxy binary also keeps the credential. | ❌ Off | ✅ Works | To keep the prompt cache warm, the proxy sends the exact same prompt again with the user's credential. Without the text, it cannot ping. The Ping button (`POST /api/me/cache/ping`) uses the same body and key. With keep-alive off, a request that carries the header `x-context-guru-ping: 1` is still held, for the button only: no ping is sent for it, and the body and key are released 300 seconds after the last request on a 5-minute cache, or 59 minutes after it on a 1-hour cache (a press does not extend it), and one account holds at most 16 such threads. Without the header nothing is held. The install adds the header and tells the user. An older install (from before `--no-ping-header`) gets it at its next session start, with the same notice. Any other install without the header is never changed. It gets a one-time note instead. The cache-state answer also carries the time of the next planned ping (a number, metadata), so the mod can hide the button while a ping fires before the cache expires. |
| **Body stash** | content | ❌ **Should be off. Today it is still on**, with 2 full bodies per thread. | ❌ Off. The sweep's question then cannot be asked, and `cache_aware_summarizer` stops. | ✅ Works | To ask the model a cheap question, Context Guru adds the question to the exact text it sent last turn. The provider already cached that text. The sweep keeps **2 more full copies of the conversation per thread**, outside the stash, for a thread the keep-alive can ping (see `extract_llm_sweep` above). |
| Observe-mode store | content | ❌ **Should follow the level. Today it is still a real Store.** | It should follow the level | ✅ Works | Observe mode runs the pipeline later on a copy, to estimate savings. The copy should store only what the real run would store. | |
|
The approvals of
Assisted-By: Claude Opus 5.5 |
Fixes CodeQL alert 6 (go/incorrect-integer-conversion). Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
CodeQL alert 6 fixed in 6a1f582, at the owner's choice.
Full diff --git a/internal/compactionpoint/bobcodex.go b/internal/compactionpoint/bobcodex.go
index 3e58573c..6bede39a 100644
--- a/internal/compactionpoint/bobcodex.go
+++ b/internal/compactionpoint/bobcodex.go
@@ -155,7 +155,7 @@ func (c Codex) Resolve(window int) (Point, bool) {
return Point{}, false
}
}
- n, err := strconv.ParseInt(strings.ReplaceAll(strings.TrimSpace(c.Limit), "_", ""), 10, 64)
+ n, err := strconv.ParseInt(strings.ReplaceAll(strings.TrimSpace(c.Limit), "_", ""), 10, 32)
if err != nil || n <= 0 || n > 1<<40 {
return Point{}, false
} |
Live checks after merge: Codex passes, Bob passes on the fallback pathThe owner approved both checks. Setup:
(c) Codex 0.160.0: passThe throwaway
(b) Bob Shell 1.0.3: pass, on the 200,000 fallbackNo Bob setting was set. One
Cleanup
Assisted-By: Claude Opus 5.5 |
Behavior change
This PR changes C for Bob users who changed nothing, and for Codex users who set a limit.
model_auto_compact_token_limit. A hosted proxy reads nothing and is unchanged. Claude Code is unchanged.compressionThreshold x window. The default is 0.5.model.compressionThreshold = 0.8on 200,000: old 199,200, new 160,000.model_auto_compact_token_limit. With 180,000 on a 400,000 window: old 400,000, new 180,000. No Codex default is used (see below).frac x C). Bob savings figures drop, because C is smaller.CONTEXT_GURU_CLIENT_COMPACT_CONFIG=offin the proxy's env. C then comes from the table, as before.Approval: approved by the owner (David Amid) on 2026-11-08. See #964 (comment).
Summary
model.compressionThresholdonce at start. It uses the user's value, else Bob's own default 0.5.model_auto_compact_token_limitonce at start. It uses the user's value. With no value, Codex stays on the table.configured(user setting) orclient_default(new, Bob only).What changed
internal/compactionpoint/bobcodex.go:Bob.ResolveandCodex.Resolve. New sourceClientDefault.Point.FromClientandRecordedhandle both sources. No import ofproxy.proxy/compactioncfg.go:ReadBobCompact,ReadCodexCompact.compactionPointForpicks the rule byclientOf(User-Agent prefixbobshell/,codex; Claude Code as before).cmd/context-guru-proxy: reads both once at start, local mode only.apply/opts.go,proxy/modes.go,components/component.go,dash/compactepisode.go,dash/event.go,dash/replaycap.go. Dash code that tested forconfigurednow also acceptsclient_default(isClientSource).docs/how-to/agent-compaction.md,docs/data-dependence.md.What we verified in each client
Bob Shell 1.0.3 (
bundle/bob.js, read only)model.compressionThreshold, schema default.5, "restart required".~/.bob/settings.json(user),.bob/settings.json(project), system file (BOB_SHELL_CLI_SYSTEM_SETTINGS_PATH, else/Library/Application Support/Bob-Shell/settings.jsonon macOS,/etc/bob-shell/settings.json). Merge order: system defaults, user, project (trusted folder), system. Last wins. No env override.Eue, methodcompress): compact whengetLastPromptTokenCount() >= T x ex(model).T = config.getCompressionThreshold() ?? 0.5(fla = .5).lastPromptTokenCountisusageMetadata.promptTokenCountof the last response. That is the provider-reported prompt size, the same ruler as billed input.ex(model)is the whole window from Bob's own catalog:GET /inference/v1/model/info, fielddata[].model_info.max_input_tokens, 200,000 if missing. No reserve.min(our window, Bob's window). The proxy reads Bob'smax_input_tokensfrom the model/info response that passes through it, and keeps one number for each model id in memory (at most 512). If it has not seen that response, it usesmin(our window, 200,000), which is Bob's own fallback. A lower C is the safe side. The same rule applies to the user's fraction.compressionThresholdgives Bob's default 0.5. A bad Codex value gives the table.bobshell/(Bob Shell sendsbobshell/<version>) orcodex(Codex sendscodex_cli_rs/...). This is narrower than the dashboard'sAgentFor, which stays as it is. So ClientToBilled = 1.0 is right for Bob, not a guess. After a compaction Bob seeds the count withJSON length / 4until the next response.CONTEXT_COMPRESSION_THRESHOLD) that Bob uses when the user set nothing. If that flag is set for a user, the real default is not 0.5 and C is off. Bob's own docs show a different key (chatCompression.contextPercentageThreshold, 0.7); the code does not use it.Codex CLI 0.160.0 (source at tag
rust-v0.160.0, read only)model_auto_compact_token_limit(tokens), top level of$CODEX_HOME/config.toml(default~/.codex;codex-rs/utils/home-dir/src/lib.rs,config/src/config_toml.rs). No env override.protocol/src/openai_models.rsModelInfo::auto_compact_token_limit,core/src/session/context_window.rs):limit = min(configured or catalog limit, 0.9 x context_window). Compact whenactive_context_tokens >= limit.active_context_tokensis the last response'stotal_tokens(input plus output) plus estimates for later items. It is close to the next request's billed input. Factor taken as 1.0, not measured.models-manager/models.json) hasauto_compact_token_limit: nullfor every model. So the default is 0.9 x Codex's own catalog window (272,000 gives 244,800). The user can replace the catalog (model_catalog_json; this machine does). Our window for the same model differs (872,000 for gpt-6-sol in the catalog). This is not a stable value, so I did not use a default. Codex stays on the table when no key is set.model_auto_compact_token_limit_scope = "body_after_prefix"andmodel_post_turn_compact_threshold_percent > 0. With either set, no C is derived (fail open).Data dependence
Metadata only. The proxy reads three short values from two config files, holds them in memory, and writes a number and a source on each row. Off, metadata only, everything: same behavior. The
docs/data-dependence.mdrow is updated. "Decided by" keeps David Amid.For Bob, the local proxy also reads the model list that passes through it (
/inference/v1/model/info). It keeps one window number for each model id, in memory only, at most 512 entries, replaced on each fetch, and never written anywhere. A hosted proxy captures nothing.How it was tested
On the box (
~/cgssh2),-race, head c10301e:go test -race ./proxy/...,./dash/...,./internal/compactionpoint/,./apply/...,./components/...,./cmd/...: all ok.gofmt -lclean,go vetclean.bobshell/andcodexUser-Agent match (bobcat/1.0,my-bob-tool/2,xcodex/1use the table); the/compactrow for abobshell/request hasclient_defaultand 100,000; the replay-cap and episode walks with aclient_defaultrow.bob;IsClientSourcewithoutclient_default.boborcodex.Open questions
None. The owner answered all three on the PR (comment 6725469580).
Technical notes
go.mod). It stops at the first[table]. A key set inside a[profiles.x]table is not read.🤖 Generated with Claude Code