Repository navigation
refactor(apply): size gates say bytes; the split floor counts real tokens (#798) - #848
Conversation
…kens (#798) - upgradeHeadTTL gates on len(body) >= head_ttl_min_bytes (default 200000). head_ttl_min_tokens is deprecated and still works: x4 when the new key is unset. - splitVolatileTail counts both checks with tokens.Count behind a cheap byte pre-check. - coref approxTokens and cg-selarm tok say they are bytes proxies on purpose. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
e8004f9 to
dc65236
Compare
…ts the config (#798) The plugin and the proxy binary are released separately. An older proxy rejects head_ttl_min_bytes (strict YAML). A new proxy reads 50000 tokens as the 200000-byte gate, so nothing changes. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
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.316 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | 736cd2cd23fa |
approve |
Verdict: approve
Findings
None. The rename is exact and the one behavior change is disclosed.
What I verified, in proof form:
- The head-TTL gate does not move. Old gate:
len(body)/4 < minTokensrefuses, so the upgrade fires whenlen(body) >= 4*minTokens(integer division makes this exact). New gate: bytes =minTokens * 4, fires whenlen(body) >= 4*minTokens. I checked all three sources of the value:- default: old 50000, new 200000 = 50000 x 4 — same boundary (
apply/headttl.go:93,config/config.go:234); - an old config key:
Resolved()givesHeadTTLMinTokens * 4(config/config.go:273-278) — same boundary; - a stored strategy:
resolveHeadTTLreturnsbest.HeadTTLMinTokens * headTTLBytesPerToken(proxy/keepalivestrategy.go:159) — same boundary.
- default: old 50000, new 200000 = 50000 x 4 — same boundary (
- Every tenant path resolves before use.
r.tn.Cacheis built only bycachePolicy(cmd/context-guru-proxy/main.go:1116,1130), which callsc.Resolved(). SoHeadTTLMinBytesis never 0-by-accident where the old code passed tokens.headTTLMin(on, n)keeps the "off means 0" rule, andapplystill testsHeadTTL1h && HeadTTLMinBytes > 0(apply/apply.go:433). No other host sets theseapply.Optsfields (proxy/modes.go,cmd/cg-transcript-replay,dash/adaptcompaction.gochecked). - The byte prefilter in the split is sound.
len(txt) >= minSplitTokensandat >= minSplitTokensare necessary conditions: one o200k token covers at least one byte, so a text under 1024 bytes cannot hold 1024 tokens (apply/prefixsplit.go:109,120). The tokenizer then runs only on a block that has a marker, and its count is memoized (internal/tokens/tokens.go). - The split-floor change is the PR's stated purpose and is disclosed at the top of the PR, with who it affects, old and new behavior, and how to turn it off — the CLAUDE.md rule for behavior changes. Dense text now splits below 4096 bytes; repetitive text no longer splits above it. Both directions have a test (
apply/prefixsplit_test.go:529) whose fixtures self-check their premise. - Existing split fixtures still clear the new floor. Every existing test uses
blockWithGitTail(6000)(~29 KB of English, well over 1024 real tokens),writeback_test.go:112(10 KB of English) andccbody_test.go:29(7.2 KB of English). The conformance test's "small first block that names a volatile marker" stays out: it is under 1024 bytes, so the new byte prefilter refuses it before any counting. - The form cannot corrupt an old document.
ParseFormreads the raw (unresolved) cache block, so an oldhead_ttl_min_tokens: 50000round-trips as 50000 withhead_ttl_min_bytesunset;ApplyFormwrites only positive values (config/form.go:402-411), so a re-save keeps the same 200000-byte gate. When both keys exist, the new key wins, andTestHeadTTLMinKeysLoadFromYAMLpins it. - The plugin's choice is safe in both directions.
settings.pykeepshead_ttl_min_tokens: 50000. An old proxy gates at len/4 >= 50000; this proxy gates at >= 200000 bytes. Identical. Writing the new key would break an old proxy's strict YAML load, so keeping the old key is the correct order. - No data-dependence change. Both gates read sizes only.
docs/data-dependence.mdneeds no row change. - The strategy view, manager API and DB column keep the token name on purpose, and the only reader (
resolveHeadTTL) converts.EntryView/Policyare not JSON-marshaled on any route, so the field rename leaks nowhere.
Non-blocking
tenant/keepalivestrategy.go:86— the field comment still says "gates HeadTTL1h on request size". It does not say the proxy reads it as tokens x 4 bytes. That fact lives only inproxy/keepalivestrategy.go:157. Add one clause, so a reader of the tenant package alone cannot miss it.HeadTTLMinTokens * HeadTTLBytesPerToken(config/config.go:275,proxy/keepalivestrategy.go:159) can overflow for values near 2^62.validate()rejects only negatives. A wrapped value disables the upgrade where the old code enabled it everywhere. Not reachable with a sane config; an upper bound would close it.minSplitTokens = 1024is Anthropic's minimum for Opus/Sonnet. Haiku's documented minimum is 2048, andtokens.Count(o200k) under-counts Claude by ~1.4-1.7x perinternal/tokens/billedfactor.go. So on Haiku a stable half just over the floor may still not be cached. The constant is unchanged by this PR; the new comment's claim "copies the provider's minimum" is now load-bearing, so this edge is worth a line there.- The whole-block check
tokens.Count(txt) < minSplitTokens(apply/prefixsplit.go:125) is almost unreachable given the stable-half check, because the stable half is a prefix of the block. Harmless and defensive; keep or drop as you prefer. - Per CLAUDE.md, the disclosed split-floor behavior change still needs a human developer's yes before merge. The PR asks for it.
What I checked
- Full diff
7b682ae5..HEAD, both commits, and the code around every change:apply/apply.go,apply/headttl.go,apply/opts.go,apply/prefixsplit.go,config/config.go,config/form.go,proxy/modes.go,proxy/keepalivestrategy.go,proxy/campaign.go,cmd/context-guru-proxy/main.go,keepalive/types.go,tenant/keepalivestrategy.go,internal/coref/coref.go,cmd/cg-selarm/main.go,context-guru-plugin/scripts/settings.py. - Every non-test reference to
HeadTTLMin*andhead_ttl_min*in the repo, to prove the rename is complete and the deprecated key has exactly one reader per path. - All constructors of
apply.Optsandproxy.CachePolicy(CachePolicy = keepalive.Policyalias), to prove no host passes an unresolved value. - Every test fixture that uses a volatile-tail marker, to prove the new real-token floor does not silently break an existing test.
- Boundary arithmetic for the deprecated-key conversion (integer division:
len/4 >= mifflen >= 4m), so old and new gates fire on the same requests. - The PR description's behavior-change section (disclosure check only).
dash/redact.go's config allowlist: nocachekeys were listed before or after, so the new key changes nothing there.
I did not run builds or tests. Live tests are not approved for this review, and Go is not installed on this machine. I read the code only, as instructed.
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.316 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 736cd2cd23fa |
approve |
Verdict: approve
Findings
None. I traced every changed path and found no defect.
Non-blocking
- proxy/keepalivestrategy.go:219-226 — stale comment names renamed fields. The
validStrategyBoundsdoc says "the same conventionCachePolicy.HeadTTLMinTokensfollows" and quoteso.HeadTTLMinTokens > 0. Both fields are nowHeadTTLMinBytes. A reader tracing the "zero means never upgrade" rule lands on a field that no longer exists. Same fortenant/keepalivestrategy.go:86, which does not say the stored value is read as tokens x 4 bytes. - A settings-page save deletes a tuned head gate (pre-existing, not this PR).
dash/ui/app.jssaveSettingspostscache: {keepalive, head_ttl_1h}only.config.ApplyForm(form.go:400-413) deletes every tuning key the form states as 0, sohead_ttl_min_bytesandhead_ttl_min_tokensare removed from the stored document. A manager who sets a custom gate on the account page, then saves the Settings page, silently loses it. This predates the PR (head_ttl_min_tokenshad the same loss), and the plugin's 50000 equals the default, so no live harm today. Worth its own issue. keepalive.Policy.HeadTTLMinTokensrenamed toHeadTTLMinBytesis a breaking API change for any external host that sets it. Nothing in this repo sets it. The sidecar-plugin repo depends on this repo and I cannot read it from here; verify it does not reference the old field before merge.splitStableTokenschanged scale. It now reports real BPE tokens, not bytes/4. The dashboard'scachesplitSavedUSDnumerator shifts slightly for text far from 4 bytes per token. The new number is the more accurate one; only series comparisons across the change date are affected.
What I checked
- Full diff base
7b682ae5..head736cd2cd(both commits), plus the code around each hunk. - Head-TTL gate equivalence. Old:
len(body)/4 < minTokensskips. New:len(body) < minBytesskips. WithminBytes = tokens x 4,len/4 >= tholds exactly whenlen >= 4t, so old and new fire on the same bodies, boundary included. Verified inapply/headttl.go:93. - Config resolution chain. YAML ->
CacheConfig->Resolved()(old key x 4, else default 200000; new key wins) ->cachePolicy->keepalive.Policy.HeadTTLMinBytes->resolveHeadTTL->apply.Opts.HeadTTLMinBytes. Every hop carries bytes.LoadBytesvalidates negatives for both keys.cachePolicyresolves only when something is switched on, so a parked block stays parked. - Strategy path.
resolveHeadTTLreturnsbest.HeadTTLMinTokens * 4for a matching strategy. That is the same size gate the old code enforced.validStrategyBoundsstill refusesHeadTTL1h=truewith a floor <= 0, so the x4 result is always positive. The manager API and the database column keep the token-named field; no schema change. - Plugin compatibility.
settings.pykeeps writinghead_ttl_min_tokens: 50000. An old proxy rejects unknown keys (strict YAML,KnownFields(true)), so keeping the old key is required. A new proxy reads 50000 as the 200000-byte gate — the same size as before. The field still exists, so the new loader accepts the old key. - Split floor. The byte pre-filters are sound: a BPE count never exceeds the byte count, so
len(txt) < 1024orat < 1024proves the real count is under the floor. The tokenizer runs only on the one block that carries a marker, andtokens.Countmemoizes by content hash, so repeat turns hit the cache.internal/tokensfalls back to(len+3)/4only when the tokenizer fails to init, which also respects count <= bytes. - New tests.
TestSplitFloorCountsRealTokensNotBytesOverFourchecks its own premise and fails loudly if the tokenizer changes.TestHeadTTLGateIsBytesOfTheBodypins the boundary both ways. The config, form, andcachePolicytests cover default, old-key, new-key-wins, and negative-refused. Existing split fixtures (28 KB+ stable halves) stay far above the real-token floor. - Behavior-change rule. The split-floor change is named at the top of the PR, with old and new behavior and how to turn it off. The PR author is the human owner.
- Data dependence. The PR states no change; both gates read sizes only. I agree — no row in docs/data-dependence.md needs an update.
- Fail open.
upgradeHeadTTLandsplitVolatileTailstill return the input untouched on every parse problem. The split keeps concatenation byte-identical, so the model sees the same prompt.
…eapmodel (#798) - Move the minimum cacheable prefix and the o200k factor from cheapmodel to internal/modelinfo. cheapmodel and apply's prefix split call the same function. - The split floor now follows the model family (Haiku 4096, others 1024 billed tokens). - ApplyForm keeps head_ttl_min_bytes and head_ttl_min_tokens when the form does not send them. - Bound both head-gate keys so tokens x 4 cannot overflow. - keepalive.Policy keeps HeadTTLMinTokens as a deprecated alias (HeadTTLGateBytes). - Fix stale comments. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Fixed in 5058827. One reply per item:
Tests, |
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.316 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | 5058827a903b |
approve |
Verdict: approve
Findings
None. The fix commit is correct and I found no new defect in it.
Earlier findings, and their state
Mine (round 1, all non-blocking):
- Stale comments naming
HeadTTLMinTokens. Fixed.proxy/keepalivestrategy.go:220-233now namesHeadTTLMinBytesand says the stored field is read as tokens x 4 bytes.tenant/keepalivestrategy.go:86-89says the same. - A settings save erased a tuned head gate. Fixed for both head keys.
config/form.go:412-420writeshead_ttl_min_bytes/head_ttl_min_tokensonly when the form states them, and leaves them alone otherwise.TestApplyFormKeepsTheHeadGateWhenTheFormDoesNotSendItcovers both spellings. The behavior change is on the PR's list (item 3). keepalive.Policy.HeadTTLMinTokensrename broke external hosts. Fixed. The field stays as a deprecated alias, andHeadTTLGateBytes()(keepalive/types.go:281-286) resolves it. I checked the boundary: an external host that set 50000 got the old gate "len(body)/4 >= 50000", which is len >= 200000; the alias returns 200000 bytes againstlen(body) >= minBytes— the same bodies.TestHeadTTLGateBytespins it.splitStableTokenschanged scale. Now disclosed as behavior change 2 in the PR body.
Reviewer 2's (round 1, all non-blocking), checked myself:
- tenant comment — fixed, same as my item 1.
tokens x 4overflow — fixed.config.validate()refuseshead_ttl_min_bytesover 1 GiB andhead_ttl_min_tokensover 268435456 (config/config.go:298-301);validStrategyBoundsrefuses the same for strategies (proxy/keepalivestrategy.go:255-258). Tests cover both.Resolved()can no longer overflow.- Flat 1024 floor ignored the family and the unit. Fixed, and beyond the note: the measured rule moved to
internal/modelinfo/cachefloor.go, and the split now usesMinCacheableO200k(model). Reviewer 2 cited a documented Haiku minimum of 2048; the author used the measured 4096 thatcheapmodelalready ships. I checked the direction: with the 1.20 divisor, the derived Haiku floor (3413 o200k) is above the true one (3555 billed at 1.152x would be 3568 o200k — the comment's own arithmetic), so it errs toward demanding more, never less. Accept. - Whole-block check almost unreachable. Dropped by the author. Sound: the stable half is a prefix of the block, so
count(txt) >= count(txt[:at]) >= flooralways held; the check could never fire. - Human yes for the behavior change. The PR body now lists four behavior changes at the top, each with who, old, new, and turn-off. The author is the human owner.
Non-blocking
- proxy/conformance_test.go:249 — stale comment. It still says "the split's minSplitTokens floor (1024)". The constant is gone; the floor is now 853-3413 o200k tokens by family. The property it documents still holds (the small block stays under the byte pre-filter), so this is a doc fix only.
- The other cache tuning keys are still erased by a settings save.
ApplyFormstill deleteskeepalive_idle_seconds,keepalive_max_pings,keepalive_min_prefix_tokensandkeepalive_max_usd_per_pingwhen the form states 0, and the settings page does not send them. The fix covered only the head-gate keys. Pre-existing on main; worth its own issue, not this PR.
What I checked
- Last review: round 1,
736cd2cd23faa0fd623fc5a40b25ce5dba556236, 2026-11-02T10:50:59Z. - New commits read: 1 —
5058827a"refactor(modelinfo): one cache-floor rule for the prefix split and cheapmodel (#798)". - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files; the inline list is empty).
- New items since my last review: the fix commit and the author's reply comment of 2026-11-02T11:30:24Z. I read both in full and checked every claim in the reply against the code.
On the new commit:
- The moved rule is byte-identical for cheapmodel.
internal/modelinfo/cachefloor.gocarries the same constants (4096/1024), the same 1.20 divisor, and the same family switch thatcheapmodelhad. The aliases incheapmodel/cachecontrol.gopoint at them, so cheapmodel's behavior cannot move. - The split's new floor is sound at every step.
MinCacheableO200kreads the model from the body;Familymatches a substring afterNormalize, soaws/claude-sonnet-5reads as Sonnet and an unplaceable alias gets the larger Haiku floor (conservative). The byte pre-filters still hold: a BPE count never exceeds the byte count, solen(txt) < floororat < floorproves the real count is under it.apply.goalready readsmodelfrom the body the same way in three other places, so the Converse-shaped path is no worse than existing practice, and a miss fails toward not splitting. - The dropped whole-block check is provably dead. The stable half is a prefix of the block, so its count bounds the block's count from below.
- The new tests self-check their premises.
stableOfcomputes the repeat count from the measured tokens-per-line, andTestSplitFloorFollowsTheModelFamilyasserts the fixture sits between the two floors before using it.writeback_test.gonow names a Sonnet model because its fixture was sized for the split — the right fix, not a fixture shrunk to pass. - The upper bounds close the overflow. Both keys are bounded in
config.validate()(reached byLoadBytesand byForm.validate), and the strategy create and update paths callvalidStrategyBounds. A pre-existing database row above the bound would overflow to a non-positive gate, whichapply's own> 0test then treats as off — the fail-safe direction. HeadTTLGateBytesis applied once.modes.gopassesr.tn.Cache.HeadTTLGateBytes();cachePolicyalways fillsHeadTTLMinByteswhen the upgrade is on, so the deprecated path only matters for an external host. The keeper's strategy resolution still converts on its own and does not double-convert.- No leftover references.
minSplitTokensis gone from non-test code; the one remaining mention is the stale conformance-test comment above.
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.316 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | 5058827a903b |
approve |
Verdict: approve
Findings
None. The fix commit is correct, and every round-1 item is addressed.
Status of earlier findings
My round-1 non-blocking items:
- Stale comment in
tenant/keepalivestrategy.go:86— fixed. The comment now says the proxy reads the stored value as tokens x 4 bytes. - Overflow of
HeadTTLMinTokens * 4— fixed.config.validate()refuseshead_ttl_min_bytesover 1 GiB andhead_ttl_min_tokensover 268435456 (config/config.go:298).validStrategyBoundsrefuses the same bound for strategies (proxy/keepalivestrategy.go:255). Tests pin both (config/headgate_test.go,proxy/keepalivestrategy_test.go:187). The bound is exact: 2^28 x 4 = 2^30, no wrap. - Haiku's 2048/4096 minimum vs the flat 1024 floor — fixed beyond my note. The floor is now per family, in one rule shared with cheapmodel (
internal/modelinfo/cachefloor.go). - Redundant whole-block token check — dropped by the author. I checked the reason: the breakpoint sits after the stable half, and the cached prefix at that point covers everything before it, which is at least the stable half. Gating on the stable half alone is the provider's own rule. The reason is right. Accepted.
- Human yes on the behavior change — still pending. The PR body lists four behavior changes at the top and asks for it.
Reviewer 1's round-1 items (I checked each myself):
- Stale comments in
proxy/keepalivestrategy.goandtenant/keepalivestrategy.go— fixed. Both now nameHeadTTLMinBytesand the tokens-x-4 reading. - A settings save erased a tuned head gate — fixed.
ApplyFormwrites the head-gate keys only when the form states them and leaves them alone otherwise (config/form.go:412-419).TestApplyFormKeepsTheHeadGateWhenTheFormDoesNotSendItpins both spellings. Named as behavior change 3 in the PR. - Breaking rename of
keepalive.Policy.HeadTTLMinTokensfor external hosts — fixed. The field stays as a deprecated alias,HeadTTLGateBytes()converts (tokens x 4 when only the old field is set, new field wins), andproxy/modes.go:56reads through it.TestHeadTTLGateBytespins all four cases. Old downstream code compiles and behaves as before: tokens x 4 bytes is the same boundary the oldlen(body)/4gate enforced. splitStableTokenschanged scale — disclosed as behavior change 2 in the PR.
The new commit (5058827)
I read the full diff and the code around each change. What I verified:
- The per-family floor is sound.
MinCacheableO200kconverts the billed floor (Haiku-class 4096, Sonnet/Opus 1024) with the measured 1.20 divisor: 3413 and 853 o200k tokens. On Sonnet, 853 x 1.20 = 1024 billed exactly, and the measured Sonnet factor (1.56) makes the true floor lower, so the split never demands less than the provider caches. The loose-divisor trade-off on Haiku (a breakpoint between 3413 and 3555 o200k is ignored, not charged) is the same measured, documented choice cheapmodel already made. - The byte prefilter still holds. The floor is now up to 3413, and one o200k token still covers at least one byte, so
len(txt) >= floorandat >= floorremain valid necessary conditions (apply/prefixsplit.go:103,116). - The model is read from the right place.
gjson.GetBytes(body, "model")runs before anything rewrites the body (the envelope transforms andupgradeHeadTTLdo not touchmodel).modelinfo.Familymatches tier words inside prefixed ids ("aws/claude-sonnet-5"). A body with no model, or an alias, gets the Haiku floor — the documented conservative default, the same rule cheapmodel applies to an unnameable model. Claude Code's real snapshot block (~6.9k stable tokens) still clears even the Haiku floor, so the common case still splits. - The cheapmodel move changes no value.
MinCacheableHaiku/MinCacheableSmall/RealTokensPerO200k/MinCacheablePrefixare the same numbers, now ininternal/modelinfo; cheapmodel keeps unexported aliases. No import cycle: modelinfo imports nothing from cheapmodel or apply. - The form fix cannot corrupt a document. A gate key is written only when the form states a positive value; otherwise the stored key stands. A plain settings save (which posts only
keepaliveandhead_ttl_1h) keeps either spelling. Removing a gate now needs a YAML edit — that is the disclosed trade-off, and no UI ever sent these fields. - The bounds close the overflow.
MaxHeadTTLMinBytes = 1<<30; the tokens bound isMaxHeadTTLMinBytes/4. The form'svalidate()goes through the sameCacheConfig.validate(), so the bound covers the settings path too. - Tests match the new behavior.
TestSplitFloorFollowsTheModelFamilyandTestSplitFloorOnSonnetIsInO200kUnitsfail against the old flat 1024 (the author's claim; the fixtures sit between 853 and 3413, so a flat 1024 would split the Haiku case and refuse the 900-token Sonnet case — the claim checks out by arithmetic). The writeback fixture's model was renamed fromclaude-xtoclaude-sonnet-5becauseclaude-xis unnameable and would take the 3413 floor, which its ~2.6k-token stable half misses — the right fix, and it shows the unnamed-model path was considered. All other split fixtures useclaude-sonnet-5or stable halves far above 3413.
Non-blocking
- Stale test comments:
proxy/conformance_test.go:249still says "the split's minSplitTokens floor (1024)", andproxy/ccbody_test.go:25says "over cachesplit's 1024-token floor (~4 chars/token)". The floor is now per-family in o200k tokens. Comments only. - The PR body's "What changed" still says the cheap check is
len(txt) >= 1024. The behavior list at the top is correct and detailed; this middle line lags the fix commit. - A user cannot clear a head gate through the settings form any more; it needs a YAML edit. Disclosed as behavior change 3. Acceptable, worth knowing.
- The four behavior changes still need the human developer's yes before merge. The PR asks for it.
What I checked
- Last review: round 1, 736cd2c, 2026-11-02T10:50:12Z.
- New commits read: 1 (5058827 "refactor(modelinfo): one cache-floor rule for the prefix split and cheapmodel (#798)").
- Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files; the inline file is empty).
- New items since my last review:
- Commit 5058827 — full diff plus the code around each hunk:
apply/prefixsplit.go,apply/prefixsplit_test.go,apply/writeback_test.go,cheapmodel/cachecontrol.go,config/config.go,config/form.go,internal/modelinfo/cachefloor.go,keepalive/types.go,proxy/keepalivestrategy.go,proxy/modes.go,tenant/keepalivestrategy.go, and the three new test files. - The author's reply comment (2026-11-02T11:30:24Z) — all seven items checked against the code, as listed under "Status of earlier findings".
- The updated PR body — the four behavior changes are named at the top, per the CLAUDE.md rule.
- Commit 5058827 — full diff plus the code around each hunk:
modelinfo.Family/Normalize(prefix and alias handling),schema/wire.go(the model key exists on every wire shape the split runs on; a missing model falls to the documented Haiku default).- Every test fixture that asserts a split, to prove the per-family floor does not silently break one:
prefixsplit_test.go,writeback_test.go,ccbody_test.go,conformance_test.go, and the small-block fixtures inkeepaliveandproxytests. - The floor arithmetic: 1024/1.20 = 853 and 4096/1.20 = 3413 o200k, and the direction of the divisor error against the measured 1.148-1.56 factors.
- The overflow bound: 2^28 x 4 = 2^30, no int wrap; bound enforced in config load, form validate, and strategy create/patch.
- No leftover
minSplitTokensreferences in code (one stale test comment, listed above); no directHeadTTLMinBytesread that should go throughHeadTTLGateBytes.
I did not run builds or tests. Live tests are not approved for this review, and Go is not installed on this machine. I read the code only, as instructed.
… send (#798) - ApplyForm writes a tuning key only when the form states it (above 0). 0 means "not stated" and leaves the stored key alone. One loop covers all keys. - Form.CacheReset names keys to delete, so "back to the default" stays possible. - Reword a stale comment in proxy/conformance_test.go. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Fixed in the new head.
|
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.316 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 3 of 3 | e4cc8437d176 |
approve |
Verdict: approve
Findings
None. The fix commit is correct and I found no new defect in it.
Earlier findings, and their state
My round-2 non-blocking items:
- Stale comment in
proxy/conformance_test.go:249. Fixed. It now names the per-family floor (modelinfo.MinCacheableO200k). - The other cache tuning keys were still erased by a settings save. Fixed.
ApplyFormnow uses one loop for all seven tuning keys: a value above 0 is written, 0 means "not stated" and leaves the stored key alone (config/form.go:404-424).Form.CacheResetnames keys to delete, so "back to the default" stays possible. Two tests pin both directions. The behavior change is item 3 on the PR's list, updated to name all seven keys and the new field.
Reviewer 2's round-2 non-blocking items, checked myself:
proxy/ccbody_test.go:25stale comment ("cachesplit's 1024-token floor, ~4 chars/token") — not fixed. The fixture usesclaude-sonnet-5and a ~6.7 KB stable half (~1,500 o200k tokens), so it still clears the 853 floor and the test holds. Comment only.- PR body "What changed" still says the cheap check is
len(txt) >= 1024— not fixed. The behavior list at the top is correct and detailed; this middle line lags the per-family floor. Doc only. - A head gate cannot be cleared from the settings form — now it can, through
cache_reset. The settings page does not send it yet; the account editor and the API can.
What I checked
- Last review: round 2,
5058827a903b5d37f64b4d8016f9775b1640846c, 2026-11-02T11:34:33Z. - New commits read: 1 —
e4cc8437"fix(config): a settings save keeps every cache tuning key it does not send (#798)". - Read in full: 3 reviews, 2 comments, 0 inline comments (from the three files; the inline file is empty).
- New items since my last review: commit
e4cc8437and the author's reply comment of 2026-11-02T11:46:37Z. I read both in full and checked every claim in the reply against the code.
On the new commit:
- The one-loop rule is sound for every key. A value above 0 is written; 0 leaves the stored key alone; a key named in
CacheResetis deleted only when the form does not also state a positive value (thev > 0cases come first). An unknown name inCacheResetmatches nothing in the loop and is ignored, so the field cannot deletekeepalive,head_ttl_1h, or any key outside the seven. - The float64 detour cannot lose precision. Every field except
keepalive_max_usd_per_pingis anintinCacheForm, and JSON decoding refuses a fractional number for anintfield, sofloat64(int)and back is exact. The head-gate keys are bounded byvalidate()(1 GiB, far under 2^53), andForm.validateruns beforeApplyFormwrites anything, so no unbounded value reaches the loop. - No caller relied on the old delete-on-0. The settings page posts only
keepaliveandhead_ttl_1h, and its own comment ("the tuning fields are omitted, which leaves the document's own values alone") now matches the server for the first time.ctlKeepAliveOffre-saves a form read byParseForm, which states every key the document carries, so its round trip is unchanged. - The tests match the behavior.
TestApplyFormKeepsEveryCacheTuningKeyItDoesNotSendcovers the five keepalive keys (the two head keys were covered by the round-2 test);TestApplyFormCacheResetDeletesNamedKeysOnlychecks that a reset deletes only the named keys. - The conformance comment fix matches the code. The floor is
modelinfo.MinCacheableO200kper family; the small-block case it documents still holds, because the block stays under the byte pre-filter. - PR body updated. Behavior item 3 now names all seven keys and
cache_reset, and states that the settings page does not use the reset field yet.
I did not run builds or tests. Live tests are not approved, and Go is not installed on this machine. I read the code only.
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.316 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 3 of 3 | e4cc8437d176 |
approve |
Verdict: approve
Findings
None. The new commit is correct, and it closes the last open review item.
Status of earlier items
My round-2 non-blocking items:
- Stale test comments — half fixed.
proxy/conformance_test.go:249now namesmodelinfo.MinCacheableO200kand the per-family floor.proxy/ccbody_test.go:25still says "over cachesplit's 1024-token floor (~4 chars/token)". Comment only. - PR body's "What changed" lags — not fixed. It still says the cheap check is
len(txt) >= 1024. The behavior list at the top is correct; only this middle line is stale. - A head gate cannot be cleared from the form — now addressed with a real mechanism:
Form.CacheResetnames the keys to delete (config/form.go:115-118). The settings page does not use it yet; that is disclosed. - Human yes on the behavior changes — still pending. The PR body still heads the list with "need a human developer's yes".
Reviewer 1's round-2 non-blocking items (I checked each myself):
- Stale conformance comment — fixed in this commit.
- The other cache tuning keys were still erased by a settings save — fixed. This is what
e4cc8437exists for, and it is the subject of the verification below.
The new commit (e4cc843)
I read the full diff, the code around it, and every caller. What I verified:
- One rule for all seven tuning keys, and it is the right rule. A value above 0 is written. 0 means "not stated" and leaves the stored key alone. A key named in
Form.CacheResetis deleted (config/form.go:410-427). For every key, 0 is also the default, so the author's claim holds: 0 could never say "back to the default" on purpose, and the reset list is the only way to say it. - Every
ApplyFormcaller survives the change. Four call sites, each checked:proxy/keepalivectl.go:301andproxy/toolfilterctl.go:213build the form withParseFormfrom the current document, so their tuning fields carry the document's own values. A key present in the document is written back as before; a key absent from it had a 0 that used to "delete" a key that was not there — a no-op either way. No regression.proxy/adaptctl.go:153setsf.Cache = nil, so the cache block is never touched.proxy/control.go:1297is the settings save the fix targets: the page posts onlykeepaliveandhead_ttl_1h, and the stored tuning keys now survive. That is the intended behavior change, named as item 3 in the PR body with all seven keys listed.
CacheResetcannot delete anything arbitrary. The reset map is consulted only inside the loop over the seven known keys, so a name outside that set is ignored. No path deletespreset,pipelineor a component block through it.- Invalid input still cannot reach the write.
ApplyFormcallsf.validate()first (config/form.go:381), andForm.validateruns the cache block throughCacheConfig.validate(), which rejects negative values and the new upper bounds. - The float64 conversion is exact. The int keys hold values bounded well below 2^53, so
float64(int)andint(float64)round-trip.keepalive_max_usd_per_pingkeeps its float type, as before. The switch order puts the float case first, so the dollar value is never truncated to an int. - Both new tests match the code.
TestApplyFormKeepsEveryCacheTuningKeyItDoesNotSendsaves a form with no tuning fields and checks all five stored keys plus thekeepaliveswitch.TestApplyFormCacheResetDeletesNamedKeysOnlychecks that a reset deletes only the named keys. The earlier round-trip tests still hold: a form parsed from a document carries that document's values, so a plain re-save writes them back unchanged. - The conformance comment reword says what the code now does.
Non-blocking
proxy/ccbody_test.go:25still says "over cachesplit's 1024-token floor (~4 chars/token)". The floor is per-family in o200k tokens now. Comment only.- The PR body's "What changed" still says the split's cheap check is
len(txt) >= 1024; it is the per-family floor. The behavior list at the top is correct. - A typo in
cache_reset(for examplekeepalive_max_ping) is silently ignored: the save reports success and the key keeps its value. Validating the names against the seven-key set would turn that into a 400. No UI sends the field today, so nothing can hit it yet. - The four behavior changes still need the human developer's yes before merge. The PR asks for it.
What I checked
- Last review: round 2, 5058827, 2026-11-02T11:35:00Z.
- New commits read: 1 (e4cc843 "fix(config): a settings save keeps every cache tuning key it does not send (#798)").
- Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files; the inline list is empty).
- New items since my last review:
- Reviewer 1's round-2 review (2026-11-02T11:34:33Z) — read in full. Its two non-blocking items are the conformance comment and the other cache keys; both are addressed by this commit, and I verified each myself above.
- The author's reply comment (2026-11-02T11:46:37Z) — read in full. Both items and the meaning-of-0 argument checked against the code. The argument is right: 0 is the default for every key, so it cannot carry a separate "off" meaning, and the reset list is the only clean way to say "back to the default".
- Commit e4cc843 — full diff plus the code around each hunk:
config/form.go,config/headgate_test.go,proxy/conformance_test.go.
- All four
ApplyFormcall sites (proxy/control.go:1297,proxy/keepalivectl.go:301,proxy/adaptctl.go:153,proxy/toolfilterctl.go:213), to prove the leave-alone rule breaks none of them. Form.validateand its place insideApplyForm, so negative or out-of-bound values cannot reach the write path.- The
CacheResetconsumption path, to prove it can only name the seven known keys. - The updated PR body — behavior change item 3 now lists all seven keys and the new
cache_resetfield, per the CLAUDE.md rule.
I did not run builds or tests. Live tests are not approved for this review, and Go is not installed on this machine. I read the code only, as instructed.
…mment Round-3 note on #848: the volatileSystemText comment still named the old flat 1024-token floor. It now names modelinfo.MinCacheableO200k. Comment only. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Round 3 notes from reviewer 2, fixed:
|
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.316 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 4 of 4 | 354e1fce3f81 |
approve |
Verdict: approve
Findings
None. The new commit changes one comment line, and it says what the code does.
Status of earlier items
My round-3 non-blocking items:
proxy/ccbody_test.go:25stale comment — fixed in354e1fce. The comment now names the per-family floor (modelinfo.MinCacheableO200k) instead of the old flat "1024-token floor (~4 chars/token)". The fixture itself is untouched:claude-sonnet-5with a ~1,500-o200k-token stable half still clears the 853 floor, so the test holds as before.- PR body's "What changed" lag — fixed. The line now says the byte pre-check uses the model's floor from
modelinfo.MinCacheableO200k(model). I read the current body back from the server. - A typo in
cache_resetis silently ignored — still open. A reset name outside the seven known keys matches nothing and the save reports success. No UI sends the field, so nothing can hit it today. Non-blocking. - Human yes on the four behavior changes — still pending. The PR body still heads the list with "need a human developer's yes". Merge should not happen without it.
Reviewer 1's round-3 review (11:48:43Z) raised nothing new; it approved and flagged the same two stale-doc items, both now fixed.
The new commit (354e1fc)
One changed line, proxy/ccbody_test.go:26, a comment on a test fixture. No code, no behavior, no test logic. The new wording is accurate: the split floor comes from modelinfo.MinCacheableO200k per model family. Nothing else in the commit.
Non-blocking
- A typo in
cache_resetis still silently ignored. Validating the names against the seven-key set would turn it into a 400. Nothing can hit it until a UI sends the field. - The four behavior changes still need the human developer's yes before merge. The PR asks for it.
What I checked
- Last review: round 3, e4cc843, 2026-11-02T11:49:07Z.
- New commits read: 1 (354e1fc "test(proxy): name the per-family split floor in the ccbody fixture comment").
- Read in full: 5 reviews, 3 comments, 0 inline comments (from the three files; the inline list is empty).
- New items since my last review:
- Reviewer 1's round-3 review (2026-11-02T11:48:43Z) — read in full. It approved
e4cc8437and listed the same two stale-doc items I did. Nothing new to check beyond that. - The author's reply comment (2026-11-02T11:50:29Z) — read in full. Both claims verified: the ccbody comment against the commit diff, and the PR body line against the server.
- Commit 354e1fc — full diff (one comment line) plus the fixture around it: the model is
claude-sonnet-5and the stable half is ~7.2 KB of English, far over the 853-o200k Sonnet floor, so the test's premise is unchanged.
- Reviewer 1's round-3 review (2026-11-02T11:48:43Z) — read in full. It approved
- The current PR body, read back from the server: behavior item list intact, the "What changed" line fixed, the header still asking for the human yes.
I did not run builds or tests. Live tests are not approved for this review, and Go is not installed on this machine. I read the code only, as instructed.
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.316 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 4 of 4 | 354e1fce3f81 |
approve |
Verdict: approve
Findings
None. The new commit changes one comment, and the comment is now right.
Earlier findings, and their state
- My round-3 items (conformance comment, settings-save erasure of tuning keys) — both fixed in
e4cc8437, verified in round 3. Nothing new on them. - Reviewer 2's round-3 items, checked myself:
proxy/ccbody_test.gostale comment — fixed in354e1fce. The comment now namesmodelinfo.MinCacheableO200k.- PR body "What changed" lag — fixed. The line now says the byte pre-check uses the model's floor from
modelinfo.MinCacheableO200k(model). Verified on the server. - A typo in
cache_resetis silently ignored — I agree, after checking the code myself in round 3: a name outside the seven-key set matches nothing in the loop, so the key keeps its value. The failure is silent but safe, and no UI sends the field today. Non-blocking. - The human yes on the four behavior changes — still pending, and the PR asks for it. The author is the human owner.
Non-blocking
- Agree with reviewer 2, round 3, item 3: validating
cache_resetnames against the seven-key set would turn a typo into a 400 instead of a silent no-op. Worth a follow-up when a UI starts sending the field.
What I checked
- Last review: round 3,
e4cc8437d176cac20fb09ff65100d2f9d61b3a48, 2026-11-02T11:48:43Z. - New commits read: 1 —
354e1fce"test(proxy): name the per-family split floor in the ccbody fixture comment". - Read in full: 4 reviews, 3 comments, 0 inline comments (from the three files; the inline file is empty).
- New items since my last review:
- Reviewer 2's round-3 review (2026-11-02T11:49:07Z) — read in full. Its verification of the four
ApplyFormcall sites matches what I found in round 3. - The author's comment (2026-11-02T11:50:29Z) — read in full. Both claims checked: the ccbody comment fix is in the diff, and the PR body line is updated on the server.
- Commit
354e1fce— the full diff is one comment line inproxy/ccbody_test.go:26. I read the file around it. The fixture usesclaude-sonnet-5and a ~6.7 KB stable half, so it clears the 853 o200k Sonnet floor and the test still holds. No code change, no behavior change.
- Reviewer 2's round-3 review (2026-11-02T11:49:07Z) — read in full. Its verification of the four
I did not run builds or tests. Live tests are not approved, and Go is not installed on this machine. I read the code only.
- One list of cache tuning keys (CacheForm.tuningValues) feeds the write loop and the cache_reset check, so a typo cannot report success. - Form.validate returns an error that names the typo and the valid keys. The settings handler returns it as a 400. Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Fixed in the new head.
|
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.316 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 5 of 5 | 0b5773f16454 |
approve |
Verdict: approve
Findings
None. The fix is correct and closes the last open review item.
Earlier findings, and their state
- The
cache_resettypo was silently ignored (reviewer 2, round 3; I agreed in round 4) — fixed in0b5773f1.Form.validatenow rejects a name outside the seven-key list, with an error that names the typo and lists the valid keys (config/form.go:601-611). The settings handler returns anApplyFormerror as a 400, so the typo is visible to the caller. - All other items from rounds 1-4 are fixed and verified in those rounds. Nothing regressed.
What I checked
- Last review: round 4,
354e1fce3f81bf019fe12ba4c314e4e982474e38, 2026-11-02T11:51:38Z. - New commits read: 1 —
0b5773f1"fix(config): reject an unknown name in cache_reset (#798)". - Read in full: 6 reviews, 4 comments, 0 inline comments (from the three files; the inline file is empty).
- New items since my last review:
- Reviewer 2's round-4 review (2026-11-02T11:51:33Z) — read in full. It approved the comment-only commit and kept the
cache_resettypo and the human yes as the open items. - The author's comment (2026-11-02T12:03:40Z) — read in full. All three claims checked against the code, below.
- Commit
0b5773f1— full diff plus the code around each hunk.
- Reviewer 2's round-4 review (2026-11-02T11:51:33Z) — read in full. It approved the comment-only commit and kept the
On the new commit:
- One key list, two readers.
CacheForm.tuningValues()(config/form.go:137-147) holds the seven keys and the stated values. TheApplyFormwrite loop and thecache_resetcheck both read it, so the two can no longer drift — the exact structure I would have asked for. - The write path is unchanged. The loop body is byte-for-byte the old switch over the same map, now built by the method. No value, key, or precedence moves.
- The validation is placed correctly.
Form.validateruns beforeApplyFormwrites anything, andctlUpdateMemaps anApplyFormerror to a 400. The check sits before thef.Cache != nilblock, so it also guards a form that names a reset without a cache object — stricter, never looser. sortandstringswere already imported inconfig/form.go, so the new code compiles with no import change.- Tests match the behavior.
TestApplyFormRejectsAnUnknownCacheResetNamechecks the error names both the typo and a valid key. The control test PUTs a typo through/api/meand expects a 400 that names the key — the handler path, not just the library path. - Nothing user-visible changes.
cache_resetships in this same PR and no UI sends it, so turning a silent no-op into a 400 is not a behavior change on any existing client.
The one thing still open before merge is the human developer's yes on the four behavior changes, which the PR body asks for at the top.
I did not run builds or tests. Live tests are not approved, and Go is not installed on this machine. I read the code only.
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.316 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 5 of 5 | 0b5773f16454 |
approve |
Verdict: approve
Findings
None. The new commit closes my last open item, and it is correct.
Status of earlier items
My round-4 non-blocking items:
- A typo in
cache_resetis silently ignored — fixed in0b5773f1.Form.validatenow rejects a name outside the seven tuning keys, and the error names the typo and lists the valid keys (config/form.go:601-611). The settings handler returns that error as a 400 (proxy/control.go:1297-1301). Verified below. - The four behavior changes need the human developer's yes — still pending. The PR body still heads the list with "need a human developer's yes".
Reviewer 1's round-4 review raised nothing new. Its one non-blocking item was the same cache_reset typo; both of us flagged it, and this commit fixes it.
The new commit (0b5773f)
I read the full diff and the code around each change. What I verified:
- One key list, no drift.
CacheForm.tuningValues()holds the same seven keys with the same values the write loop used to build inline (config/form.go:138-148). The write loop (config/form.go:427) and the new validation both read it, so a key cannot be writable but not resettable, or the reverse. - Validation runs before any write.
ApplyFormcallsf.validate()first (config/form.go:394-397), so a typo cannot delete or keep anything. The check works whenf.Cacheis nil: it runs on a fresh&CacheForm{}, not onf.Cache. - The 400 is real.
control.go:1297-1301returns anApplyFormerror as a 400 with the error text.TestApplyFormRejectsAnUnknownCacheResetNamechecks the error names the typo and a valid key; the control test PUTs a typo and asserts the 400 and the message (proxy/control_test.go:646-654). - No internal caller can trip the check. Only the JSON request body sets
Form.CacheReset. The other threeApplyFormcall sites (keepalivectl.go:301,toolfilterctl.go:213,adaptctl.go:153) build forms fromParseForm, which never sets it. I grepped the repo: no non-test code setsCacheResetbesides the decode. - No new behavior change against main.
cache_resetitself is new in this PR, so rejecting unknown names defines the new field. It fails safe: the save is refused with a clear message, and the stored document keeps its keys. No CLAUDE.md disclosure is required, and the PR body's item 3 already describes the field.
Non-blocking
- The four behavior changes still need the human developer's yes before merge. The PR asks for it. Merge should not happen without it.
- Optional: PR body item 3 could say that an unknown
cache_resetname is a 400. Not required, because the field is new in this PR.
What I checked
- Last review: round 4, 354e1fc, 2026-11-02T11:51:33Z.
- New commits read: 1 (0b5773f "fix(config): reject an unknown name in cache_reset (#798)").
- Read in full: 6 reviews, 4 comments, 0 inline comments (from the three files; the inline file is empty).
- New items since my last review:
- Reviewer 1's round-4 review (2026-11-02T11:51:38Z) — read in full. It approved
354e1fceand agreed with mycache_resettypo item. Nothing new to check beyond that. - Commit 0b5773f — full diff plus the code around each hunk:
config/form.go(tuningValues, the write loop, validate),config/headgate_test.go,proxy/control_test.go,proxy/control.go:1297-1301. - The author's reply comment (2026-11-02T12:03:40Z) — read in full. All four claims checked against the code, as listed under "The new commit".
- Reviewer 1's round-4 review (2026-11-02T11:51:38Z) — read in full. It approved
- Every
CacheResetreference in the repo, to prove only the JSON decode sets it. Form.normalizeandForm.validate, to prove validation runs before any write and nothing stripsCacheReset.- The current PR body, read back from the server: the four behavior changes are intact, item 3 names the field, and the header still asks for the human yes.
I did not run builds or tests. Live tests are not approved for this review, and Go is not installed on this machine. I read the code only, as instructed.
…0.2.9) (#863) Claude Code plugin 0.6.4 -> 0.6.5: - #850: 12 display-only skills get disable-model-invocation: true. - #738: an optional beep when Claude finishes or needs input. - #848: settings.py still writes head_ttl_min_tokens, so an older proxy loads its config. - #859: the band and cg.py show "finished" for an agent that ended with a terminal tool call. Codex plugin 0.2.8 -> 0.2.9: - #850: 9 display-only skills get allow_implicit_invocation: false. - #852: the session skill's front matter is valid YAML, so Codex loads it. Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
Behavior changes (need a human developer's yes)
Current branch:,Recent commits:) and a cache breakpoint (thecachesplitstep).cheapmodeluses. It now lives once, ininternal/modelinfo/cachefloor.go.cachesplitandcacheinject. The floor has no switch.splitStableTokenschanges scale: it is a real o200k count (tokens.Count), not bytes/4. The dashboard prices the saving from it (dash.Event.cachesplitSavedUSD), so the number shown moves for the same block.keepalive_idle_seconds,keepalive_openai_idle_seconds,keepalive_max_pings,keepalive_min_prefix_tokens,keepalive_max_usd_per_ping,head_ttl_min_bytes,head_ttl_min_tokens. Before,ApplyFormdeleted them when the form stated 0, and the settings page does not send them. This bug is older than this PR. Now 0 means "not stated" and leaves the key alone. 0 is also the default for each key, so a new form fieldcache_reset(a list of key names) says "back to the default" and deletes the named keys. The settings page does not use it yet.head_ttl_min_bytesover 1 GiB, orhead_ttl_min_tokensover 268435456, is refused at load.The head-TTL gate itself does not change: default 200000 bytes (old 50000 x 4). An old config with
head_ttl_min_tokensgates at the same size.Summary
Closes #798. Size gates now say bytes. A provider rule now counts real tokens.
What changed
apply/headttl.go: gate islen(body) >= minBytes.cache.head_ttl_min_bytes(default 200000) inconfig/config.go,config/form.go,apply/opts.go,apply/apply.go,keepalive/types.go,proxy/modes.go,cmd/context-guru-proxy/main.go, pluginsettings.py. The plugin does not write the new key (see Open questions).head_ttl_min_tokensis deprecated and still works. Ifhead_ttl_min_bytesis unset, the gate is tokens x 4. If both are set, bytes wins.head_ttl_min_tokens.resolveHeadTTLreads it as tokens x 4 bytes. No schema change.apply/prefixsplit.go: cheap check first: the block and its stable half must each hold at least as many bytes as the model's floor,modelinfo.MinCacheableO200k(model)(a block never has more tokens than bytes). Thentokens.Counton the stable half, only for the block that has a marker.internal/modelinfo/cachefloor.go(new):MinCacheableO200k(model)and friends, moved fromcheapmodel.cheapmodel/cachecontrol.gokeeps thin aliases, so its callers and values are unchanged.keepalive.Policy.HeadTTLMinTokensstays as a deprecated alias.HeadTTLGateBytes()converts it (tokens x 4) whenHeadTTLMinBytesis 0, so a downstream host that sets it still builds and behaves as before.internal/coref/coref.goapproxTokensandcmd/cg-selarm/main.gotok: comments say they are bytes proxies on purpose. Values are unchanged.components/offload/collapse.go: untouched, as agreed. It re-measures with the real tokenizer.docs/how-to/cache-keepalive.md.Other
/4estimates found on main: none that gate a request.internal/extract/elide.go:207is a character budget, not a token estimate.components/offload/dedup.go:169is*3/4of a string, not tokens.Data dependence
No change. Both gates use sizes only. At every storage level (off, metadata only, everything) the behavior is the same.
How it was tested
On the eval box,
-race:./apply/...,./config/...,./internal/...,./cmd/...,./keepalive/...,./context-guru-plugin/...,./proxy/...all pass.gofmt -lis clean.go vetis clean on the touched packages.New tests:
TestSplitFloorCountsRealTokensNotBytesOverFour: fails on oldprefixsplit.go, passes now (both directions).TestHeadTTLGateIsBytesOfTheBody.TestHeadTTLMinBytesResolution,TestHeadTTLMinKeysLoadFromYAML: old key only = 200000, new key wins, negative refused.TestFormRoundTripsHeadTTLMinBytes: the settings form round-trips the new key.TestCachePolicyCarriesTheHeadGateInBytes.TestResolveHeadTTLMatchingStrategyOverridesTheAccount(50000 tokens = 200000 bytes), plugin1-hour-headgate test.Open questions
head_ttl_min_bytes(strict YAML). Sosettings.pykeeps writinghead_ttl_min_tokens: 50000for1-hour-head. A new proxy reads it as the 200000-byte gate, so nothing changes. The plugin should writehead_ttl_min_bytesin a later release, when no supported proxy is older than this one.head_ttl_min_bytesonly when the user sets it. It is served by the proxy that holds the config, so it cannot talk to an older proxy.Assisted-By: Claude Opus 5.5 [email protected]