Repository navigation
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Component
general
Description
The MS JS distro (0.1.0-beta) LangChainTraceInstrumentor mis-attributes the LLM response model into the gen_ai.request.model attribute and never sets gen_ai.response.model. The actual request deployment alias is also lost in some flows. The bug reproduces across three LangChain code paths and also affects span naming.
Affected scenarios
1. LangChain Node.js – AzureChatOpenAI – Chat Completions API (CAPI)
- Span name:
chat gpt-3.5-turbo gen_ai.request.model:o4-mini-2025-04-16← wrong (this is the response model)gen_ai.response.model: (empty)- Prompt tokens: 18 / Completion tokens: 0
- Root cause: The instrumentor reads
LLMResult.llmOutput.model_name(the response model) and writes it togen_ai.request.model, conflating the two attributes. The actual request deployment alias is dropped entirely. The span name falls back to LangChain''s defaultmodelfield (gpt-3.5-turbo) because nomodelkwarg is passed toAzureChatOpenAI.
2. LangChain Node.js – ChatOpenAI (Foundry) – Chat Completions API (CAPI)
- Span name:
chat deployment-o4-mini gen_ai.request.model:o4-mini-2025-04-16← wrong (this is the response model)gen_ai.response.model: (empty)- Prompt tokens: 5 / Completion tokens: 0
- Root cause: Same as Initial Microsoft Distro Scaffolding #1 — the response model is mis-attributed into
gen_ai.request.model. Here the span name picks up the deployment string (deployment-o4-mini) because it is passed as themodelkwarg.
3. LangChain Node.js – ChatOpenAI (Foundry, useResponsesApi) – Responses API (RAPI)
- Span name:
chat deployment-o4-mini gen_ai.request.model:deployment-o4-minigen_ai.response.model: (empty)- Prompt tokens: 4 / Completion tokens: 0
- Root cause: The LangChain callback path doesn''t extract a model from the Responses-API result object (the field shape differs from Chat Completions), so it falls back to the request deployment for
gen_ai.request.modeland leavesgen_ai.response.modelempty.
Expected Behavior
gen_ai.request.modelshould be the model/deployment requested by the caller (the deployment alias for Azure/Foundry, or themodelkwarg passed to the client).gen_ai.response.modelshould be populated fromLLMResult.llmOutput.model_name(Chat Completions) or the equivalent field in the Responses-API result object.- Span name should follow GenAI semantic conventions and use the request model.
- Across all three scenarios above, the request and response model attributes should be distinct and both populated.
Steps to Reproduce
- Install
@microsoft/opentelemetry-distro-javascript(or the appropriate LangChain instrumentation package) at version0.1.0-beta. - Configure the distro to instrument LangChain.
- Reproduce each of the three scenarios:
a. Build aAzureChatOpenAIclient (CAPI) without passing amodelkwarg, and invoke it.
b. Build aChatOpenAIclient pointed at Foundry (CAPI) with the deployment passed as themodelkwarg, and invoke it.
c. Build aChatOpenAIclient pointed at Foundry withuseResponsesApi: true(RAPI), and invoke it. - Inspect the resulting spans:
gen_ai.request.modelcontains the response model (Initial Microsoft Distro Scaffolding #1, Add planning and other md files #2) or the request deployment with no response model set (Migrate AzMon Distro #3).gen_ai.response.modelis empty in all three cases.
Environment
- OS: any
- Node.js: 20.x
- Package version:
@microsoft/opentelemetry-distro-javascript0.1.0-beta - LangChain: Node.js
- Runtime: standalone Node.js
Additional Context
Suggested fix
- Stop writing
LLMResult.llmOutput.model_nametogen_ai.request.model. Route it togen_ai.response.modelinstead. - Source
gen_ai.request.modelfrom the invocation params / client configuration (e.g., the deployment alias for Azure/Foundry, or themodelkwarg). - Add a Responses-API-specific extractor for the response model so
gen_ai.response.modelis populated whenuseResponsesApiis enabled. - Add tests covering all three paths above (
AzureChatOpenAICAPI,ChatOpenAIFoundry CAPI,ChatOpenAIFoundry RAPI).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
github-actions commentedon May 8, 2026
cc Hector Hernandez (@hectorhdzg) Jackson Weber (@JacksonWeber) Leighton Chen (@lzchen) Nev (@MSNev) Radhika Gupta (@rads-1996) Jeremy Voss (@jeremydvoss)
fpfp100 commentedon May 8, 2026
The reason that gen_ai.response.model is not set because it is not in A365 Observability schema. It is by design based on the schema. Attributes which are not in the schema will be discarded by ingestion service.
The reason that response model is used to set request model attribute is because nodejs langchain bug which does not set gen_ai.request.model properly for AzureChatOpenAI. Using gen_ai.response.model generates the name which is very closed to the actual request model e.g gen_ai.request.model: o4-mini-2025-04-16 instead of always "gpt-3.5-turbo".
The suggestion for #1, #2 does not work for AzureChatOpenAI as mentioned above and the current implementation is a work around. Based on the investigation on the bug, it seems the right fix is to keep the current workaround for AzureChatOpenAI client. For ChatOpenAI client, fix the setting gen_ai.request.model as suggested in the bug.
For #3, not required for A365 Observability schema, it is a no op, but might need for Azure foundry scenario.
fix(langchain): scope AzureChatOpenAI request-model workaround per fp…
fix(langchain): split request/response model and emit gen_ai.response…
fix(langchain): populate gen_ai.response.model for Responses API (use…