refactor(agent): return streamedTurn from streamWithFrozen - #7786
Merged
Conversation
streamWithFrozen returned 13 positional values whose only consumer immediately repacked them into streamedTurn via the streamTurnFrozen wrapper. Return the struct directly, delete the wrapper, and share a collect helper across the mid-stream exit paths. No behavior change.
This was referenced Aug 7, 2026
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.
Part of the agent god-object cleanup series (agent.go grew to 4.7k LOC / Agent to 99 fields over the last 6 weeks).
What
streamWithFrozenreturned 13 positional values; its only consumers werestream(same tuple) andstreamTurnFrozen, whose sole purpose was to repack the tuple into the existingstreamedTurnstruct. It now returnsstreamedTurndirectly.streamTurnFrozenwrapper;streamWithSamplingRecoverycallsstreamWithFrozendirectly.collecthelper; the clean-terminal and intercept-error paths keep explicit literals because they run under theinterceptProviderResponseshadowed scope and override fields (partialToolStartedforced false on clean terminal, now stated in a comment instead of an anonymous positionalfalse).Pure mechanical repack — no behavior change.
Verification
gofmtclean,go vet ./internal/agent/...cleango test ./internal/agent/andgo test -race ./internal/agent/greengo test ./...green (English locale)Cache-impact: none - pure mechanical repack of streamWithFrozen return values into the existing streamedTurn struct; no request building, cache_control placement, or usage accounting logic changes.
Cache-guard: existing coverage - internal/agent cache_shape_test.go and usage_accounting_test.go pass unchanged (go test -race ./internal/agent/).
Documentation-impact: none - internal refactor with no user-visible behavior change; no docs describe these internals.