fix: Responses tool continuations rescan the entire session history to recover tool names#838
Closed
sam-saffron-jarvis wants to merge 1 commit into
Closed
Conversation
…o recover tool names
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.
What changed
populateResponsesToolResultNamesto prefer reverse-paged store lookups when the session store supportssession.MessagesDescendingPager.GetMessagesfallback for stores that do not implement the optional reverse pager.Why this is high-value
Responses follow-up requests that contain only
function_call_outputitems often arrive without tool names in the current payload, so the server has to recover names from prior tool-call messages.Before this change, persisted continuations could call
GetMessages(ctx, sessionID, 0, 0)and deserialize the entire transcript just to recover one or a few tool names. On long-lived, tool-heavy sessions that turns a hot follow-up request into O(full transcript) DB I/O and JSON decoding.After this change, SQLite/logging-backed stores can read only the newest tail pages and stop early once the needed call IDs are found. That reduces total rows read, JSON deserialization work, peak allocations, and continuation latency, especially when the relevant tool call is near the end of a long session.
Validation
gofmt -w cmd/serve_handlers_responses.go cmd/serve_test.gogo build ./...go test ./...TestPopulateResponsesToolResultNames_UsesReversePagedStoreLookupto verify reverse paging is used and full-historyGetMessagesis not called when the pager capability is available.