Skip to content

feat(js-sandbox): support snapshotName and list filters#2770

Merged
Daniel Kneipp (DanielKneipp) merged 2 commits intomainfrom
daniel/js-snapshot-name-and-list-filters
Apr 22, 2026
Merged

feat(js-sandbox): support snapshotName and list filters#2770
Daniel Kneipp (DanielKneipp) merged 2 commits intomainfrom
daniel/js-snapshot-name-and-list-filters

Conversation

@DanielKneipp
Copy link
Copy Markdown
Contributor

@DanielKneipp Daniel Kneipp (DanielKneipp) commented Apr 22, 2026

Summary

Follow-up to #2758 — extends the snapshot-only sandbox surface so callers can boot from a snapshot name (not just an ID) and so listSnapshots supports server-side filtering and pagination.

Sibling to the Python SDK change: #2769.

Stacked on #2758. GitHub will auto-retarget the base to main once that PR merges.

createSandbox — accept snapshotName

snapshotId becomes optional (positional) and a new snapshotName field is added to CreateSandboxOptions. Exactly one must be provided. To avoid confusion, snapshotId is intentionally not duplicated on the options object.

// By ID (unchanged):
const sandbox = await client.createSandbox(snapshot.id);

// By name — server resolves the snapshot against the caller's tenant:
const sandbox = await client.createSandbox(undefined, {
  snapshotName: "my-snap",
});

Validation throws a LangSmithValidationError if neither (or both) is provided.

listSnapshots — add ListSnapshotsOptions

const all = await client.listSnapshots();
const page = await client.listSnapshots({
  nameContains: "python",
  limit: 10,
  offset: 20,
});

All three options are optional and independent. Omitting them keeps today's zero-arg behavior — the request URL has no query string. The new type is re-exported from the sandbox public index.

Tests (src/tests/sandbox.test.ts)

  • createSandbox: new `snapshot_name` payload test + zero-identifier and both-identifier rejection tests.
  • listSnapshots: existing zero-arg test extended to assert an empty query string; new test asserts `name_contains`, `limit`, `offset` appear on the request URL.

All 80 sandbox tests pass locally.

README

  • Added a `snapshotName` example in the Snapshots section alongside the existing `snapshotId` example.
  • Added a `listSnapshots({ nameContains, limit, offset })` example.
  • Updated the API Reference rows for `createSandbox` and `listSnapshots`.
  • Added a `snapshotName` row to the `CreateSandboxOptions` table.
  • Added a new `ListSnapshotsOptions` table.

Breaking changes

None. `createSandbox(snapshotId)` calls keep working unchanged; the positional arg is now optional, but the payload behavior is identical when it is provided.

Made with Cursor

*/
async createSandbox(
snapshotId: string,
snapshotId?: string,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional nit: why not just allow this to be the name too like snapshotIdOrName: string ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just avoiding the edge case of the name having the format of an uuid

Base automatically changed from daniel/js-sdk-sandbox-cleanup to main April 22, 2026 13:44
…ilters

- Relax `createSandbox(snapshotId, options?)` so `snapshotId` is optional and
  add a new `snapshotName` field on `CreateSandboxOptions`. Exactly one of
  the two must be set (validated via `LangSmithValidationError`). The SDK
  forwards the identifier verbatim on the wire as `snapshot_id` /
  `snapshot_name`. `snapshotId` stays positional — it is intentionally not
  duplicated on the options object.
- Add a new `ListSnapshotsOptions` type (nameContains / limit / offset /
  signal) and extend `listSnapshots` to build a URLSearchParams query string
  only when at least one option is set, preserving the zero-arg URL.
- Re-export `ListSnapshotsOptions` from the sandbox public index.
- Tests: cover the snapshotName create path, the zero-identifier and
  both-identifier rejection cases, the listSnapshots zero-arg URL shape, and
  the filtered URL shape.
- README: add snapshotName and listSnapshots examples in the Snapshots
  section, update the API Reference rows for `createSandbox` and
  `listSnapshots`, add a `snapshotName` row to the `CreateSandboxOptions`
  table, and add a new `ListSnapshotsOptions` table.

Stacked on top of #2758. Sibling to #2769 (Python).

Made-with: Cursor
Document that the backend always paginates with a default page size of
50 and rejects limit values outside [1, 500] and negative offsets. Also
note that nameContains is a case-insensitive substring match.
@DanielKneipp Daniel Kneipp (DanielKneipp) force-pushed the daniel/js-snapshot-name-and-list-filters branch from 3a3e87c to 4cdccac Compare April 22, 2026 13:45
@DanielKneipp Daniel Kneipp (DanielKneipp) merged commit c9a1897 into main Apr 22, 2026
49 of 51 checks passed
@DanielKneipp Daniel Kneipp (DanielKneipp) deleted the daniel/js-snapshot-name-and-list-filters branch April 22, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants