High severity intermediate · Fix: 2-5 min

ValueError

langsmith.exceptions.ValueError: Trace parent run not found

What this error means
LangSmith raises this error when a trace parent run ID is missing or invalid during run tracking, breaking trace continuity.

Stack trace

traceback
Traceback (most recent call last):
  File "app.py", line 42, in <module>
    run = client.runs.create(...)
  File "/usr/local/lib/python3.9/site-packages/langsmith/client.py", line 120, in create
    raise ValueError("Trace parent run not found")
ValueError: Trace parent run not found
QUICK FIX
Always pass a valid, existing parent run ID to the run creation method to avoid this error immediately.

Why it happens

LangSmith requires a valid parent run ID to maintain trace continuity across runs. This error occurs when the parent run ID is missing, expired, or incorrectly passed, causing the SDK to fail linking the current run to its parent trace.

Detection

Monitor your run creation calls for ValueError exceptions and log the parent run ID being passed; missing or invalid IDs indicate this error before it crashes.

Causes & fixes

1

Parent run ID is not passed or is None when creating a new run

✓ Fix

Ensure you explicitly pass a valid parent run ID string when creating or continuing a run in LangSmith.

2

Parent run ID has expired or was deleted from LangSmith backend

✓ Fix

Fetch or create a fresh parent run ID before starting child runs to maintain valid trace linkage.

3

Incorrect environment or client configuration causing loss of trace context

✓ Fix

Verify your LangSmith client initialization and environment variables to ensure trace context is preserved and propagated.

Code: broken vs fixed

Broken - triggers the error
python
from langsmith import LangSmithClient
client = LangSmithClient()

# Missing parent run ID causes error
run = client.runs.create(name="child-run")  # ValueError: Trace parent run not found
Fixed - works correctly
python
import os
from langsmith import LangSmithClient

os.environ["LANGSMITH_API_KEY"] = os.environ["LANGSMITH_API_KEY"]
client = LangSmithClient()

parent_run_id = "valid_parent_run_id"
run = client.runs.create(name="child-run", parent_run_id=parent_run_id)  # Fixed: pass valid parent run ID
print(f"Run created with ID: {run.id}")
Added passing a valid parent_run_id parameter to the run creation call, ensuring LangSmith can link the run to its trace parent.

Workaround

Catch the ValueError on run creation, then create a new root run without a parent ID as a fallback to continue execution without trace linkage.

Prevention

Implement centralized trace context management in your app to always propagate and validate parent run IDs before creating new runs, ensuring trace continuity.

Python 3.9+ · langsmith >=0.1.0 · tested on 0.2.x
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.