Skip to content

Commit efd81ac

Browse files
fix(closes OPEN-8001): handle ValueError in _current_step.reset to manage context variable mismatches
1 parent e0c0a86 commit efd81ac

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/openlayer/lib/tracing/tracer.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,14 @@ def create_step(
402402
latency = (new_step.end_time - new_step.start_time) * 1000 # in ms
403403
new_step.latency = latency
404404

405-
_current_step.reset(token)
405+
try:
406+
_current_step.reset(token)
407+
except ValueError as e:
408+
# Handle context variable mismatch gracefully
409+
# This can occur when async generators cross context boundaries
410+
if "was created in a different Context" not in str(e):
411+
raise
412+
406413
_handle_trace_completion(
407414
is_root_step=is_root_step,
408415
step_name=name,

0 commit comments

Comments
 (0)