Repository navigation
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Dumbris
approved these changes
Oct 26, 2026
Dumbris
left a comment
Member
There was a problem hiding this comment.
Verified: the PR test fails on main for the reason described and passes on this branch merged with main; race tests for the touched packages and CI lint (bare and server tags) are clean. Also built and tested together with the rest of this batch, independently reviewed, and cross-reviewed with a second model.
Member
|
Merged. Thank you, @rudycelekli! |
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.
Bug
When a tool response is over the truncation limit,
findArraysRecursive(internal/truncate/truncator.go) collects candidate record arrays by ranging over each JSON object, andchooseBestArraypicks one. On a tie,chooseBestArraykeeps whichever candidate came first. Go randomizes map iteration, so identical payloads with equally good sibling arrays get a differentRecordPathon different calls. Theread_cachehandle minted for that response then pages a different array each time.Trigger
An upstream tool returns, for example,
{"zeta":[…20 rows], "alpha":[…20 rows], "mid":[…20 rows]}and the response is over the limit.content_forward.gocallsTruncateon every such response. Repeated identical calls returnrecord_pathvalues ofzeta,alpha, ormiddepending on map order.Fix
Object keys are now traversed in sorted order, so the tie-break is stable: the first key in sorted order wins. Non-tied selection is unchanged.
Verification
go test -count=1 -run TestTruncate_TiedArraysPickStableRecordPath ./internal/truncate/passes. The test runs 50 calls on the payload above and expectsalphaevery time.truncator.goreverted (git stash push internal/truncate/truncator.go), the same test fails:call 0: record path "zeta", want "alpha".go test -count=1 ./internal/truncate/passes.go vet ./internal/truncate/is clean.gofmt -l internal/truncate/is clean.go test -count=1 ./internal/server/locally, but it hit the default 10-minute test timeout, which isn't a result either way. A narrower rerun failed at setup because of a local build-cache error. I'm relying on CI for that package.Commands were run with
GOFLAGS=-mod=readonly CGO_ENABLED=0.