Repository navigation
fix(lcm): count replay metadata in token budgets - #4712
Closed
ScriptedAlchemy wants to merge 2 commits into
Closed
ScriptedAlchemy wants to merge 2 commits into
ScriptedAlchemy wants to merge 2 commits into
Conversation
|
This was referenced Nov 3, 2026
Owner
Author
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.
Replay selection estimated tool-call metadata with bytes/4, while the returned replay estimate and overflow flag counted only visible content. A retained tool transaction could therefore exceed the requested budget while reporting that it fit; recovery could also mistake removable tool arguments for fixed prompt overhead.
This change uses one canonical replay-envelope counter for raw transaction selection, pinned anchors, the returned estimate, and overflow-overhead subtraction. Tool arguments and other retained metadata use the existing o200k tokenizer. Role framing and local provenance remain outside that envelope, and content-only source summarization budgets retain their existing meaning.
The latest-objective preservation check now also recognizes an objective already emitted among pinned anchors. Previously it could append the same objective twice without reserving the extra budget.
Regressions cover atomic eviction of tool-heavy transactions, honest best-effort status when the newest transaction cannot fit, avoiding double reservation of tool arguments as prompt overhead, and preserving a pinned objective exactly once under an exact replay cap.
Validation
git diff --checkpass.asupersyncdependency's code generation was killed by SIGKILL at the container's 8 GiB memory limit with two workers, one worker, and the repository's existing one-workerbounded-testprofile. No dependencies, assertions, or build profiles were changed.cargo check --profile bounded-test -p tracedecay-lcm --lib --tests --lockedpassedasupersync, then stopped with 12 E0599 errors in unchangedtracedecay-graph-db, before reaching the changed LCM target. Cargo's pinned Grafeo lacks four allocation-accounting methods supplied by the repository's existing Bazel patch.MODULE.bazelapplies that patch; Cargo does not. The manifest, lockfile, graph-db sources, and dependency cache were not changed.This PR remains draft pending executable regression coverage. The root session and Hermes Cargo targets share the same baseline dependency blocker; repeating those checks would not validate the changed code.
Implemented and reviewed with GPT-6 Astra Pro in ChatGPT.