feat(platform): include jobKey in LLM Gateway trace baggage#1731
Open
RunnanJia wants to merge 1 commit into
Open
feat(platform): include jobKey in LLM Gateway trace baggage#1731RunnanJia wants to merge 1 commit into
RunnanJia wants to merge 1 commit into
Conversation
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>
Contributor
There was a problem hiding this comment.
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
jobKeyfromUiPathConfig.job_keyto the emittedx-uipath-tracebaggageentries 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}") |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Why
build_trace_context_headers(uipath/platform/chat/llm_trace_context.py) propagatesfolderKey,agentId, andprocessKeyintox-uipath-tracebaggage, but notjobKey— even thoughUiPathConfig.job_keyis available. LLM Gateway now builds the model-call span from this baggage (see the LLMGateway span work), so a missingjobKeymeans the span can't be attributed to the originating job.Today callers compensate by hand-injecting
jobKeythroughextra_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 existingprocessKeyblock:Gated by the existing
EnableTraceContextHeadersflag like the rest of the function; no behavior change when the flag is off.Note
Callers that already inject
jobKeyviaextra_baggagewill 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