feat(run): add --version v2 flag to runs query path#143
Open
Anirudh Sriram (asrira428) wants to merge 2 commits into
Open
feat(run): add --version v2 flag to runs query path#143Anirudh Sriram (asrira428) wants to merge 2 commits into
Anirudh Sriram (asrira428) wants to merge 2 commits into
Conversation
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.
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>
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.
Adds an opt-in
--versionflag torun list,run get, andrun export. When set tov2, the command routes through the SmithDB-backed v2 endpoint (POST /v2/runs/query) via the newlib/runsv2subpackage in langsmith-go. Empty /v1(the default) keeps the existing behavior.Filter flags are translated to the v2 body (split
--since/--last-n-minutes/--beforeintomin_start_time/max_start_time,--error/--no-error→has_error,--projectresolves to a session UUID and is sent asproject_ids, etc.). v2 responses are normalized back into the v1RunSchemashape 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:
LSEN-149.
Depends on langchain-ai/langsmith-go#104 —
go.modcurrently 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.goandinternal/cmd/trace_stats.gois bundled in: cost fields moved fromstring→float64onRunSchemabetweenlangsmith-go v0.10.0and current main. The SDK bump forces the fix.Release Note
The
langsmith run list,run get, andrun exportcommands now accept--version v2to query runs via the SmithDB-backed v2 endpoint.Test Plan
go build ./...— cleango vet ./...— cleango test ./...— all packages greenlangsmith run list --project <p> --version v2 --limit 5against a SmithDB-enabled tenantlangsmith run list --project <p> --version v2 --include-io --include-feedbackand confirm output matches the v1 path for the same window|| langsmith run list ...fallback works