openai: Responses API chat model event stream omits response_metadata.model_name
Checked other resources
- This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
- I added a very descriptive title to this issue.
- I searched the LangChain.js documentation with the integrated search.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangChain.js rather than my code.
- The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
import { convertOpenAIResponsesStream } from "@langchain/openai";
async function* events() {
yield { type: "response.created", response: { id: "resp_1", model: "gpt-5.4-2026-03-05" } };
yield {
type: "response.completed",
response: { id: "resp_1", model: "gpt-5.4-2026-03-05", status: "completed", output: [] },
};
}
for await (const event of convertOpenAIResponsesStream(events() as never)) {
if (event.event === "message-finish") {
console.log(event.responseMetadata);
// { model_provider: "openai", id: "resp_1", model: "gpt-5.4-2026-03-05", status: "completed" }
// model_name is missing
}
}In practice this hits every ChatOpenAI call that uses the Responses API (e.g. reasoning: { summary: "auto" }) while a chat-model stream event handler is attached, such as any call inside agent.streamEvents(..., { version: "v3" }): BaseChatModel then builds the final AIMessage from _streamChatModelEvents, so its response_metadata.model_name is undefined.
Error Message and Stack Trace (if applicable)
No response
Description
convertOpenAIResponsesStream (libs/providers/langchain-openai/src/utils/responses_stream_events.ts) builds the message-finish responseMetadata with model but not model_name:
responseMetadata = {
model_provider: provider,
id: event.response.id,
model: event.response.model,
status: event.response.status,
};Every other OpenAI path sets response_metadata.model_name to the served model:
- the core Chat Completions event stream (
buildResponseMetadatainopenai_completions_stream.ts), - the legacy Responses chunk stream (
response.createdinconvertResponsesDeltaToChatGenerationChunk), - the non-streaming Responses path (
convertResponsesMessageToAIMessage).
model_name is the field tracing integrations read the served model from. Langfuse's LangChain CallbackHandler, for example, records the requested model at handleLLMStart and overwrites it with response_metadata.model_name at handleLLMEnd. As a result, Responses API generations streamed through the v3 event protocol show up as gpt-5.4 while every other generation of the same model shows gpt-5.4-2026-03-05, which splits the model in dashboards and cost reports.
Expected: response_metadata.model_name is set to event.response.model, as on the other paths.
System Info
@langchain/openai1.6.0 (also present onmain)@langchain/core1.2.13langchain1.5.x (createAgent+streamEventsversion: "v3")- macOS, Bun 1.3 / Node 26
Source: langchain-ai/langchainjs