Repository navigation
Conversation
norci
marked this pull request as draft
November 15, 2026 11:03
norci
marked this pull request as ready for review
November 15, 2026 13:09
Contributor
Author
|
this bug fix has been verified on my machine. I created an extension for billion-context (https://github.com/norci/config-autolith/blob/main/extensions/billion-context.lisp ) |
norci
marked this pull request as draft
November 15, 2026 14:11
Evidence written before component charging is no longer usable for pricing prompt and tools, so a reloaded conversation fell back to dividing the stored characters of every retained item by four. That re-priced history the provider had already counted and pushed the estimate over the compaction limit with no new work in the conversation. Keep the measured total and history length beside the sample and start the estimate from them, charging only the history appended after the recorded count.
norci
force-pushed
the
fix/context-measurement
branch
from
November 15, 2026 23:48
487da6b to
f357b5b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A measured request keeps its occupancy until the measured policy or the measured covered history prefix changes, and every later difference is charged as a signed character difference against that measurement.
Design
The sample holds nine keys:
:format,:policy,:chargeables,:history-count,:history-digest,:wire-fields,:wire-characters,:ephemera-characters,:tokens. Both readers price their difference against it throughprovider-context--header-charge, which walks the union of measured and current(key digest characters)triples so a component that disappeared contributes zero characters. Prompt and tool components are priced from configuration-derived characters on the estimate path and from transported wire-field characters on the admission path.Conversation storage validates the sample shape and keeps the recorded
:tokensand:history-countof every:context-usagerecord as a baseline, whatever shape its evidence has. The estimate path uses that baseline when no sample is usable, so a conversation loaded from durable records resumes from the last measured total and charges only the history appended since.One rejection condition: a changed policy (class, model, model-provider, endpoint) or a rewritten covered history prefix (digest or count), because the tokenizer identity and the covered prefix have to be provable before a measurement can be extended.
Why
Correctness
provider-context--matched-inputon admission andcontext-estimate-known-tokenson the estimate path both price throughprovider-context--header-charge.Cost
Durability
Evidence
./script/check --suite context-admission --jobs 8: 27 cases, 268 checks, 0 failed../script/check --jobs 12: 1,788 cases, 32,438 checks, 2 failed. Both fail without these changes:test-world-server-restart-checkpointreproduces onf04e6142, andtest-lisp-worker-protocolneeds an SBCL source root this host does not provision.Cost
Before any measurement exists the estimate is characters divided by four. Once one exists it resumes from the recorded total, and history appended since then is priced by serialized characters rather than by the tokenizer's own count.