Fix/turn budget - #100
Merged
Merged
Conversation
added 3 commits
September 8, 2026 14:59
The 75%-full check in ReplTurn.cs only ever printed a suggestion to run /compact manually. In practice this let sessions ride at 75%+ context for many turns with no automatic shrinkage, contributing to oversized turns that burn excess tool-call rounds (observed hitting the 50-round backstop in session f6544c76, turn 11). The check now prefers the provider-reported actual input-token count for the turn (ctx.LastActualContextTokens) over the char-based estimate when available, and calls the existing ReplCommands.CompactHistoryAsync path (already proven via the adaptive-trim-forced auto-compact) instead of only warning. Falls back to the old warn-only text if compaction fails. Adds a repl.autoCompact setting (default on) to opt back into the old warn-only behavior via /settings set repl.autoCompact false.
TruncateArgValue replaces oversized FunctionCallContent argument values (e.g. a write_file content arg) in already-completed, same-turn tool calls with a short size note before resending history to the model on a later round, to bound per-round context growth. The old placeholder text read enough like a real value that the model has been observed re-echoing it verbatim into a brand-new, live tool call - e.g. when asked to move a file it had written earlier in the turn, it reconstructed the content argument from its own (by then elided) history and wrote the placeholder string itself to disk. The filter never mutates a pending/about-to-execute tool call - this was the model treating its own truncated context as ground truth. Reword the note to explicitly warn against reuse and point to the correct recovery (re-read the file or regenerate the value).
…olders TrimInTurnContext's two elision placeholders replace/truncate tool *results* (e.g. a large read_file output) in-turn, the same way TruncateArgValue elides oversized call arguments. They had the same latent risk: a vague placeholder that could be mistaken for real data and echoed into a later, live tool call (e.g. treating an elided read_file result as the file's actual contents when writing it elsewhere). Reword both to be explicit about what they are: - The full-replacement placeholder (Phase 1) now says outright it is not the real output and must not be reused as data. - The proportional-truncation suffix (Phase 2) is different in kind: the content before it IS real, only the tail was cut. Reworded to say so explicitly, so the model doesn't treat the retained prefix as the complete result.
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.
No description provided.