Repository navigation
Conversation
|
🔍 OpenCodeReview found 1 issue(s) in this PR.
[bug · medium] 📄
|
|
Addressed the reviewer bot's finding in a1d3b78: the success return of |
|
Really appreciate your contribution, but the size of the change seems too large than I expected, with multiple fixes or irrelative modifications applied in a single PR. The "no-tool retry path had no token bound" issue emerged from the bug in function My advice is to fix the "no-tool retry path" with a neat implementation in this PR, and left the background compression issue in another PR (better with a separate issue too). Thanks again for your impressive analysis the context compression issues and your rich contribution, wish you have a good day! |
When the model answers without tool calls, the retry path appended the assistant text and retry nudge directly to the conversation, bypassing compression entirely — a model that keeps chatting without tools grows the prompt unchecked until the provider rejects it. Root cause in two parts. groupIntoRounds only recognized assistant and tool roles, so retry nudges belonged to no round: even when compression did run, partition boundaries and token accounting never saw those messages. Rounds now span from their assistant message to the next one, covering tool results and interleaved user messages alike. On top of that, the retry path now goes through the same append+compression helper as tool rounds (addNextMessage generalized to appendMessagesWithCompression, taking the whole logical update at once), and its success predicate is the exact complement of the sync-compression trigger, so a conversation sitting exactly at the warning threshold is not misreported as a failure. TestRunPerFile_NoToolRetryBoundedByCompression fails on the old retry path (10 LLM calls, StopMaxRounds) and passes with the fix (1 call, StopCompression).
a1d3b78 to
35cde9e
Compare
|
Thanks for the direction — you're right on both counts, and the PR is reworked accordingly. Scope: this PR is now only the no-tool retry bound (single commit,
|
|
@Fanzzzd The direction here is right, but this branch has drifted far from |
Description
Scoped down per review feedback: this PR now fixes only the no-tool retry bound. The compression-zone defects that were previously bundled here (background compression summarizing the live tail, unreserved frozen-zone budget, template-less truncation) moved to #838 with standalone reproductions.
When the model answers without tool calls, the retry path appended the assistant text + retry nudge directly to
messages, bypassing compression entirely — a model that keeps chatting without tools grows the prompt unchecked until the provider rejects it.The fix addresses the root cause in two parts:
groupIntoRoundscould not see retry messages. It only recognizedassistantandtoolroles, so the user retry nudges belonged to no round: even when compression did run, partition boundaries and token accounting skipped them. Aroundnow spans from its assistant message to the next assistant message (or the end of the conversation), covering tool results and interleaved user messages alike — which also simplifies the boundary math tocompressEnd = lastCompressRound.end.addNextMessageis generalized toappendMessagesWithCompression, taking one whole logical update at a time so thresholds are evaluated once per round and compression never runs between an assistant message and its tool results. Its success predicate is the exact complement of the sync-compression trigger (<= warnLimit), so a conversation sitting exactly at the warning threshold is not misreported as a failure.Behavioral change: a retry loop that overflows the budget now stops with
StopCompressioninstead of growing until a provider error. No wire-format changes.Type of Change
How Has This Been Tested?
make testpasses locallyTestRunPerFile_NoToolRetryBoundedByCompressiondiscriminates: with the old retry path restored it fails (retries keep going,StopMaxRounds); with the fix it passes (1 LLM call,StopCompression)TestGroupIntoRounds_RetryNudgesStayWithTheirRoundpins the new round span on the retry shape; the existingTestGroupIntoRoundsis updated to the span representation with identical boundaries for assistant+tool sequencesChecklist
go fmt,go vet)Related Issues
Related to #838 (the compression-zone defects split out of this PR) and #806 (originally split out of it).