Populate gen_ai.response.model from responses API when the response body includes the served model header - #305
Merged
Conversation
Pull request dashboard statusMerged · refreshed 2026-08-03 14:55 UTC Status above doesn't look right?
|
rads-1996
force-pushed
the
respect-rapi-headers
branch
from
July 23, 2026 21:41
e986ddb to
cc0cf57
Compare
Contributor
Author
rads-1996
force-pushed
the
respect-rapi-headers
branch
3 times, most recently
from
July 30, 2026 16:51
dd53ba4 to
29f323a
Compare
rads-1996
marked this pull request as ready for review
July 30, 2026 16:52
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the LangChain GenAI instrumentation to prefer a concrete “served model” value exposed via Responses API response headers when available, improving the accuracy of gen_ai.response.model for deployments where the response body only echoes the requested deployment name.
Changes:
- Add header-based resolution for
response_model_name(e.g.x-ms-served-model) with fallback to existingllm_output["model_name" | "model"]. - Add unit tests covering header precedence, case-insensitivity, and fallbacks.
- Add a towncrier changelog fragment for the new capability.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| instrumentation/opentelemetry-instrumentation-genai-langchain/src/opentelemetry/instrumentation/genai/langchain/callback_handler.py | Prefer served-model response header when present to populate response_model_name |
| instrumentation/opentelemetry-instrumentation-genai-langchain/tests/test_callback_handler.py | Add tests validating header extraction and precedence over llm_output |
| instrumentation/opentelemetry-instrumentation-genai-langchain/.changelog/305.added | Record the user-visible behavior change in release notes |
eternalcuriouslearner
approved these changes
Jul 30, 2026
eternalcuriouslearner
approved these changes
Jul 30, 2026
eternalcuriouslearner
left a comment
Contributor
There was a problem hiding this comment.
LGTM!! Thanks for the quick turnaround.
rads-1996
force-pushed
the
respect-rapi-headers
branch
from
July 31, 2026 16:51
f82c3d5 to
d45a49d
Compare
lmolkova
approved these changes
Aug 2, 2026
…ody includes the served model header
rads-1996
force-pushed
the
respect-rapi-headers
branch
from
August 3, 2026 14:19
d45a49d to
93212c0
Compare
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.


Description
Fixes # (267)
Type of change
Please delete options that are not relevant.
How has this been tested?
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. List any relevant details for your test
configuration.
Checklist
See CONTRIBUTING.md
for the style guide, changelog guidance, and more.