- Know the run ID ahead of time (e.g., to attach feedback immediately after a run).
- Correlate LangSmith runs with IDs from an external system.
- Make runs idempotent by reusing a deterministic ID.
We recommend using UUID v7 custom run IDs. UUIDv7 embeds a timestamp, which preserves correct time-ordering of runs in a trace. Passing a non-UUIDv7 ID currently emits a warning, and will be required by a future version.The LangSmith SDK exports a uuid7 helper (Python v0.4.43+, JS v0.3.80+):
- Python:
from langsmith import uuid7 - JS/TS:
import { uuid7 } from 'langsmith'
- Python
- TypeScript
Use @traceable
Pass run_id inside langsmith_extra when calling a @traceable function:Python
Use the trace context manager
Pass run_id directly to the trace context manager constructor to set the ID for that traced block:Python
Related
- Attach user feedback: common use case for pre-specifying a run ID.
- Access the current run (span) within a traced function: read the auto-assigned ID from inside a trace.
- Trace with the LangSmith API: low-level API approach for specifying run IDs.
- Trace Vercel AI SDK applications: specifying a custom run ID with
wrapAISDK.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

