fix(core): prefer OTEL trace ID over external span when trace IDs differ by cfauchere · Pull Request #1542 · UiPath/uipath-python

@claude

When both an OTEL current span (set by the agent runtime) and an
external span (from OpenInference LangChain instrumentor) exist with
different trace IDs, get_parent_context() now returns the OTEL span.

Previously, the depth-based tiebreaker would pick the external span,
causing the agent's trace ID to be lost. Downstream services (ECS)
received a different trace ID than the agent trace, making correlation
impossible.

Validated locally: the x-uipath-traceparent-id header now carries the
same trace ID as the agent trace.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Clement Fauchere and others added 4 commits

April 2, 2026 08:02
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…iffer

Verifies that when the OTEL current span (agent runtime) and the
external span (OpenInference) have different trace IDs, the @Traced
decorator inherits the OTEL trace ID.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…test

Updated test_ctx_parameter_required_when_external_deeper_than_current
to assert the new behavior: when OTEL and external spans have different
trace IDs, OTEL span is preferred. Removed the duplicate test from
test_external_integration.py.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

RunnanJia

JosephMar

saksharthakkar

akshaylive