fix(ai): parse OpenAI-compatible reasoning deltas (v2) - #37554
Conversation
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Related PRsI found several PRs related to OpenAI reasoning parsing that may be relevant:
These PRs (particularly #35284 and #36068) address very similar issues with parsing the |
Issue for this PR
Closes #37553
Fixes #37553
Type of change
What does this PR do?
Some OpenAI-compatible providers return streamed reasoning in
delta.reasoninginstead ofdelta.reasoning_content.This adds
reasoningto the stream schema and parses it as a fallback whenreasoning_contentis absent. This matches the behavior of the AI SDK's OpenAI-compatible provider while preservingreasoning_contentprecedence.This is a regression from
v1behaviour,v1supportsreasoningfor vllm compatibility.How did you verify your code works?
Added a regression test using an SSE stream containing
delta.reasoning, followed by normal response text.Ran from
packages/ai:bun test test/provider/openai-chat.test.tsScreenshots / recordings
Not applicable; this is a protocol parsing fix.
Checklist