#16573·phoenix

REST list_experiments: no way to reach an experiment by sequence number (newest-first only, no sort/filter, no sequence_number in payload)

Author: MoraVigoMalusardiCreated Sep 28, 2026Updated Sep 28, 2026

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, limit default 50, ordered models.Experiment.id.desc() (newest-first), overfetch-by-1 for next_cursor.
  • No sort parameter and no way to filter by sequence number.
  • The Experiment response model (experiments.py:56) exposes id, name, created_at, run counts, etc., but no sequence_number field.

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_at over 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:

  1. Return the sequence number on the Experiment response model — the same 1-based, per-dataset ordinal (row_number() over (partition by dataset_id order by id)) that GraphQL's sequenceNumber and the experiment_sequence_number dataloader use.
  2. Add sequence-number-based access, via one or both of:
    • a sequence_numbers query parameter (repeatable / comma-separated) — a membership lookup returning only the experiments with those ordinals, without paging (analogous to GraphQL sequenceNumbers: [Int!]);
    • a sort parameter with a direction over sequence number / created-at (analogous to GraphQL ExperimentSort), so oldest-first can put sequences 1..N on the first page.

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 Experiment REST payload includes its per-dataset sequence number.
  • Default listing behavior is unchanged when the new parameters are absent.