Skip to content

feat(run): add --version v2 flag to runs query path#143

Open
Anirudh Sriram (asrira428) wants to merge 2 commits into
mainfrom
ani/lsen-149-update-cli-to-support-a-version-v2-flag-for-runs-query
Open

feat(run): add --version v2 flag to runs query path#143
Anirudh Sriram (asrira428) wants to merge 2 commits into
mainfrom
ani/lsen-149-update-cli-to-support-a-version-v2-flag-for-runs-query

Conversation

@asrira428
Copy link
Copy Markdown
Contributor

@asrira428 Anirudh Sriram (asrira428) commented May 28, 2026

Adds an opt-in --version flag to run list, run get, and run export. When set to v2, the command routes through the SmithDB-backed v2 endpoint (POST /v2/runs/query) via the new lib/runsv2 subpackage in langsmith-go. Empty / v1 (the default) keeps the existing behavior.

Filter flags are translated to the v2 body (split --since/--last-n-minutes/--before into min_start_time / max_start_time, --error/--no-errorhas_error, --project resolves to a session UUID and is sent as project_ids, etc.). v2 responses are normalized back into the v1 RunSchema shape so the existing extract/output pipeline is unchanged.

The CLI surfaces v2 errors as-is — fallback is the agent's job, not the CLI's, so the path that served the result is always explicit. The README is updated with the recommended pattern:

langsmith run list --project my-app --version v2 || langsmith run list --project my-app

LSEN-149.

Depends on langchain-ai/langsmith-go#104go.mod currently points at a pseudo-version of that branch; once it merges and a langsmith-go release is cut, this PR will bump to the released version before leaving draft.

A small mechanical change in internal/extract/extract.go and internal/cmd/trace_stats.go is bundled in: cost fields moved from stringfloat64 on RunSchema between langsmith-go v0.10.0 and current main. The SDK bump forces the fix.

Release Note

The langsmith run list, run get, and run export commands now accept --version v2 to query runs via the SmithDB-backed v2 endpoint.

Test Plan

  • go build ./... — clean
  • go vet ./... — clean
  • go test ./... — all packages green
  • Manual: langsmith run list --project <p> --version v2 --limit 5 against a SmithDB-enabled tenant
  • Manual: langsmith run list --project <p> --version v2 --include-io --include-feedback and confirm output matches the v1 path for the same window
  • Manual: confirm a non-rolled-out tenant returns a 4xx and the recommended || langsmith run list ... fallback works

Adds an opt-in `--version` flag to `run list`, `run get`, and `run export`
that routes through the new SmithDB-backed v2 endpoint
(`POST /v2/runs/query`) via `lib/runsv2` in langsmith-go.

- Project name is resolved to a session UUID and sent as `project_ids`.
- Filter flags are translated to the v2 body (split start/end into
  `min_start_time` / `max_start_time`, `error` -> `has_error`, etc).
- v2 responses are normalized back into the v1 `RunSchema` shape so the
  existing extract/output pipeline is unchanged.
- README adds agent guidance: try `--version v2` first, fall back to v1
  if it errors.

The CLI surfaces v2 errors as-is — fallback is the caller's (agent's)
job, not the CLI's, so the path served is always explicit.

Also bumps `langsmith-go` to pick up `lib/runsv2`, which forces a
mechanical type fix in `extract.go` / `trace_stats.go` for cost fields
that moved from string -> float64 between v0.10.0 and current main.

LSEN-149.
@asrira428 Anirudh Sriram (asrira428) marked this pull request as ready for review May 29, 2026 20:29
The v2 (SmithDB) endpoint returns metadata as a separate top-level field,
but the extractor reads custom_metadata (incl. revision_id) from
Extra["metadata"]. Fold r.Metadata back into Extra so --include-metadata
keeps working under --version v2, without clobbering a nested metadata that
some response paths already include in extra.

SmithDB does not populate status (returns null), so stop selecting and
mapping it rather than surfacing a misleading empty value.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant