fix: advance the v2 runs/query cursor in the request body - #262
Draft
Quentin Brosse (QuentinBrosse) wants to merge 1 commit into
Draft
Quentin Brosse (QuentinBrosse) wants to merge 1 commit into
Quentin Brosse (QuentinBrosse) wants to merge 1 commit into
Conversation
POST /api/v2/runs/query reads `cursor` from the JSON body, but the SDK's QueryV2AutoPaging sends it as a URL query parameter, so every follow-up request refetched the first page. Any v2 run query needing more than one page (`trace get` on traces with >100 runs, `trace list --show-hierarchy`, `trace export`, `run list`, `thread list`) returned page 1 repeated up to the caller's limit, inflating run counts and dropping later runs. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
3 tasks
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.
Description
POST /api/v2/runs/queryreadscursorfrom the JSON body, butlangsmith-go's generatedItemsCursorPostPagination.GetNextPageappliesoption.WithQuery("cursor", next)— a URL query parameter the server ignores. Every "next page" request therefore refetched page 1, soqueryRunsV2accumulated the same 100 runs until it hit the caller's limit (1000 fortrace get, i.e. 10 duplicated pages) and never reached the later runs.queryRunsV2now pages explicitly withRuns.QueryV2, settingparams.Cursor(a body field) from each response'snext_cursor, mirroring the existing v1queryRunshelper, and stops if a cursor ever repeats so an unbounded limit (thread listpassesmath.MaxInt32) cannot loop forever.Affects every v2 run query that needs more than one page:
trace get,trace list --show-hierarchy,trace export,run list,thread list.Note: the underlying SDK bug still needs an upstream fix (body-cursor paginators in
langsmith-goshould emitWithJSONSet, notWithQuery); it also affects the v1CursorPaginationauto-pager, which this CLI does not use.Test Plan
go test ./internal/cmd -run TestQueryRunsV2— new tests cover body-cursor advancement, stopping at the limit, and the repeated-cursor guard; the first one fails onmainwith page 1 duplicatedlangsmith trace get <trace-id> --project <p>against a trace with >100 runs returns each run once with an accuraterun_countMade by Open SWE