Repository navigation
fix(langchain): Record finish reasons for the OpenAI Responses API - #26800
Merged
Merged
Conversation
Co-Authored-By: Rola Abuhasna <rola.abuhasna@sentry.io>
RulaKhaled
marked this pull request as ready for review
November 24, 2026 09:13
javascript-sdk-gitflow
Bot
requested review from
JPeer264,
isaacs and
timfish
November 24, 2026 09:13
Contributor
size-limit report 📦Compared: 8c19453 (PR test merge using develop at e9013e0) Against: e9013e0 (develop) · base run #67681 ✅ Baseline matches: this diff contains only this PR's changes.
|
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 2 not successful, 65 successful. See the run.
Successful checks
|
JPeer264
approved these changes
Nov 25, 2026
JPeer264
left a comment
Member
There was a problem hiding this comment.
LGTM, also the map is simplified, I like that.
51 tasks done
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.
What
LangChain chat spans now record
gen_ai.response.finish_reasonsforChatOpenAIcalls that use the Responses API.Why
We only read
finish_reasonfromgenerationInfo/generation_info, which Chat Completions sets but the Responses API doesn't. Since@langchain/openai1.8.5 the Responses API puts it onmessage.response_metadatainstead, so we fall back to that when the generation has none.We record the raw
finish_reason(the response status, e.g.completed,incomplete) rather than LangChain'snormalized_finish_reason. This matches what the OpenAI integration already records for Responses API spans (response.status). Versions before 1.8.5 don't setfinish_reasonon the message at all, so they still record none.Closes: #26762
Fixes JS-4144
via Rola Abuhasna.
--
View Session [Sentry]