REST list_experiments: no way to reach an experiment by sequence number (newest-first only, no sort/filter, no sequence_number in payload)
Summary
The REST GET /v1/datasets/{dataset_id}/experiments endpoint (list_experiments) has the same "can't reach an experiment by its user-facing number" limitation that #16560 fixed for the GraphQL Dataset.experiments connection — but the GraphQL fix (#16563) did not extend to REST. A REST client that wants "experiment 5 and 7" on a dataset must page the entire connection and recompute the ordinal itself, and the response doesn't even carry a sequence number to check against.
Current behavior
list_experiments (src/phoenix/server/api/routers/v1/experiments.py:779):
- Cursor-paginated,
limitdefault 50, orderedmodels.Experiment.id.desc()(newest-first), overfetch-by-1 fornext_cursor. - No
sortparameter and no way to filter by sequence number. - The
Experimentresponse model (experiments.py:56) exposesid,name,created_at, run counts, etc., but nosequence_numberfield.
Consequences:
- The 1-based, oldest-first sequence number a user sees in the UI is not returned, so a REST consumer can't map a returned experiment to "experiment N" without reconstructing the ordering from
id/created_atover the full list. - Because the list is newest-first and paginated, the lowest sequence numbers are the farthest from the first page. For a dataset with more experiments than the page limit, reaching a low number means walking every page.
This is only invisible today when a dataset has ≤ 50 experiments (a single default page returns the whole ordered set); it breaks for larger datasets and for REST-only clients.
Proposed fix
Mirror the GraphQL change (#16563) on the REST endpoint:
- Return the sequence number on the
Experimentresponse model — the same 1-based, per-dataset ordinal (row_number() over (partition by dataset_id order by id)) that GraphQL'ssequenceNumberand theexperiment_sequence_numberdataloader use. - Add sequence-number-based access, via one or both of:
- a
sequence_numbersquery parameter (repeatable / comma-separated) — a membership lookup returning only the experiments with those ordinals, without paging (analogous to GraphQLsequenceNumbers: [Int!]); - a
sortparameter with a direction over sequence number / created-at (analogous to GraphQLExperimentSort), so oldest-first can put sequences1..Non the first page.
- a
Existing default behavior (newest-first, limit 50) should stay unchanged when the new parameters are not supplied. This keeps the REST and GraphQL surfaces consistent for ordinal resolution.
Context
- GraphQL parent issue: #16560
- GraphQL implementation: #16563
Acceptance
- A REST client can fetch the experiment(s) for one or more given sequence numbers on a dataset without walking every page.
- The
ExperimentREST payload includes its per-dataset sequence number. - Default listing behavior is unchanged when the new parameters are absent.
Source: Arize-ai/phoenix