fix(context): stop the artifact_read retrieval loop - #14
Merged
Conversation
A large active tool result was bounded to maxActiveResultChars and spilled to an artifact with a "use artifact_read" hint. When the model called artifact_read, that retrieval result was itself re-truncated and re-spilled, so the model looped calling artifact_read to fetch the "full output" that never surfaced (seen as ~6 repeated calls until maxTurns). Fix: exempt the retrieval tools (artifact_read, artifact_search) from active-display truncation and receipt spilling — show their output in full (they already page via offset/limit). Also raise the default maxActiveResultChars 2000 -> 8000 so ordinary tool outputs fit inline without an artifact round-trip. Regression: an active artifact_read result larger than the bound is shown in full, never re-truncated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
Problem
Observed live (native macOS app on
glm-5.2:cloud): asking the agent to list a directory made it callartifact_read~6 times in a row and never present the listing, exhaustingmaxTurns.Root cause — a self-defeating loop in
ContextManager:run_shellreturns a large listing → it's the active exchange →activeDisplayshows a 2000-char preview + "use artifact_read" and spills to artifact-A.artifact_read(A). That read's result becomes the new active exchange →activeDisplaytruncates it again to 2000 chars and spills to artifact-B.maxTurns.Retrieval was re-truncating itself.
Fix
artifact_read,artifact_search) from both active-display truncation and receipt spilling — their output is the mechanism for surfacing full content, and they already page viaoffset/limit.maxActiveResultChars2000 → 8000 so ordinary tool outputs fit inline with no artifact round-trip at all.Tests
testContextManagerDoesNotRetruncateArtifactReads: an activeartifact_readresult larger than the bound is shown in full, with no "truncated" marker.🤖 Generated with Claude Code