feat: caller-owned trace_context_extra_baggage; stop defaulting source=agents (v0.11.19)#917
Open
RunnanJia wants to merge 1 commit into
Open
feat: caller-owned trace_context_extra_baggage; stop defaulting source=agents (v0.11.19)#917RunnanJia wants to merge 1 commit into
RunnanJia wants to merge 1 commit into
Conversation
…e=agents (v0.11.19) This shared package hardcoded source=agents in the LLM Gateway trace baggage, which is wrong for any non-agents caller. source/executionType/jobKey are product-owned and must be supplied by the caller, not defaulted here. Adds a trace_context_extra_baggage parameter threaded through the new and legacy get_chat_model paths and into the OpenAI/Vertex/Bedrock legacy transports down to the per-request httpx hook. Bumps to 0.11.19. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR makes trace-context “extra baggage” (e.g., source, executionType, jobKey) caller-owned instead of hardcoding source=agents inside the shared chat-model factory, and threads the new option through both the new and legacy LLM client paths. It also bumps the package version to 0.11.19 and adds/updates tests to validate the forwarding behavior.
Changes:
- Add
trace_context_extra_baggage: list[str] | Nonetoget_chat_modeland propagate it into trace header injection. - Remove the hardcoded
extra_baggage=["source=agents"]from trace-context header creation across callback + legacy transports. - Bump version to
0.11.19and expand trace-context callback/forwarding test coverage.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Updates lock metadata and bumps uipath-langchain version to 0.11.19. |
| pyproject.toml | Bumps project version to 0.11.19. |
| tests/chat/test_trace_context_callback.py | Adds tests ensuring extra baggage defaults to None and is forwarded through legacy transports. |
| src/uipath_langchain/chat/chat_model_factory.py | Introduces trace_context_extra_baggage parameter and wires it into the trace headers callback. |
| src/uipath_langchain/chat/_legacy/openai.py | Threads extra baggage into per-request trace header injection via httpx transports. |
| src/uipath_langchain/chat/_legacy/vertex.py | Threads extra baggage into Vertex URL rewrite transports and header injection. |
| src/uipath_langchain/chat/_legacy/bedrock.py | Threads extra baggage into Bedrock request modification header injection. |
| src/uipath_langchain/chat/_legacy/chat_model_factory.py | Propagates extra baggage through the legacy chat model factory constructors. |
Comment on lines
+188
to
+192
| cb_list.append( | ||
| _TraceContextHeadersCallback( | ||
| trace_context_extra_baggage=trace_context_extra_baggage | ||
| ) | ||
| ) |
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
The chat-model factory hardcoded
extra_baggage=["source=agents"]when building LLM Gateway trace headers. That is incorrect for any caller that isn't agents —source(andexecutionType/jobKey) are product-owned attribution values and must be supplied by the caller, not defaulted in this shared package.What
source=agents.trace_context_extra_baggage: list[str] | Noneparameter toget_chat_model, threaded through the new path, the legacy path, and into the OpenAI/Vertex/Bedrock legacy transports down to the per-request httpx hook (_inject_trace_context_headers).Callers (e.g. uipath-agents-python) now pass their own
source/executionType/jobKeyvia this parameter.🤖 Generated with Claude Code