Skip to content

fix(deepseek): send the reasoning of a streamed tool call turn back - #1066

Open
skybleak333 wants to merge 1 commit into
prism-php:mainfrom
skybleak333:fix/deepseek-stream-reasoning-content
Open

skybleak333 wants to merge 1 commit into
prism-php:mainfrom
skybleak333:fix/deepseek-stream-reasoning-content

Conversation

@skybleak333

Copy link
Copy Markdown

Description

With thinking on, which is DeepSeek's default, DeepSeek needs the reasoning_content of every earlier turn back when the request carries tools: "If your code does not correctly pass back reasoning_content, the API will return a 400 error" (thinking mode guide). #1020 did that for asText(). The stream handler emitted the reasoning deltas as ThinkingEvents but didn't keep them, and added the tool call turn as new AssistantMessage($text, $mappedToolCalls), so a streamed request with tools failed on the request after the first tool call.

The stream handler now collects the reasoning of the step, like the OpenRouter and Gemini streams do, and puts it in the assistant message as reasoning_content, the same way Text does, so MessageMap sends it back.

New test: a streamed step with reasoning and a tool call, then the answer; it checks the second request carries the reasoning on the assistant message and fails without the change. The full suite, PHPStan, Pint and Rector pass. This touches DeepSeek/Handlers/Stream.php like #1054, in other lines.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant