Skip to main content
By default, LangSmith assigns a random ID to each run. You can override this with a custom ID when you need to:
  • 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'
Any UUID v7 string is accepted. You can pass one generated by the LangSmith SDK helpers, or your own if your system already uses UUID v7 identifiers.

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