Skip to content

feat(platform): include jobKey in LLM Gateway trace baggage#1731

Open
RunnanJia wants to merge 1 commit into
mainfrom
feat/trace-context-jobkey-baggage
Open

feat(platform): include jobKey in LLM Gateway trace baggage#1731
RunnanJia wants to merge 1 commit into
mainfrom
feat/trace-context-jobkey-baggage

Conversation

@RunnanJia

Copy link
Copy Markdown

Why

build_trace_context_headers (uipath/platform/chat/llm_trace_context.py) propagates folderKey, agentId, and processKey into x-uipath-tracebaggage, but not jobKey — even though UiPathConfig.job_key is available. LLM Gateway now builds the model-call span from this baggage (see the LLMGateway span work), so a missing jobKey means the span can't be attributed to the originating job.

Today callers compensate by hand-injecting jobKey through extra_baggage (e.g. uipath-agents-python). Emitting it natively here fixes it once for every caller and lets those workarounds be removed.

What

One addition in build_trace_context_headers, mirroring the existing processKey block:

if job_key := UiPathConfig.job_key:
    baggage_parts.append(f"jobKey={job_key}")

Gated by the existing EnableTraceContextHeaders flag like the rest of the function; no behavior change when the flag is off.

Note

Callers that already inject jobKey via extra_baggage will momentarily send it twice in the comma-joined header; the LLM Gateway baggage parser is last-write-wins, so this is harmless. Those callers can drop the manual injection once this ships.

🤖 Generated with Claude Code

build_trace_context_headers emits folderKey/agentId/processKey but omits
jobKey, even though UiPathConfig.job_key is available. LLM Gateway now
builds the model-call span from this baggage, so without jobKey the span
cannot be attributed to the originating job. Callers currently work around
this by hand-injecting jobKey via extra_baggage; emitting it natively fixes
it once for every caller.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 17, 2026 17:00
@github-actions github-actions Bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-integrations labels Jun 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the platform LLM trace context propagation to include jobKey in the x-uipath-tracebaggage header, enabling LLM Gateway spans to be attributed to the originating job without requiring callers to manually inject this baggage entry.

Changes:

  • Add jobKey from UiPathConfig.job_key to the emitted x-uipath-tracebaggage entries when trace context headers are enabled.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +47 to +48
if job_key := UiPathConfig.job_key:
baggage_parts.append(f"jobKey={job_key}")
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
50.0% Coverage on New Code (required ≥ 90%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-integrations test:uipath-langchain Triggers tests in the uipath-langchain-python repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants