Skip to content

deepseek-v4.1-flash returns reasoning_tokens: 1 on every tool-continuation request #1165

Open

Description

@Vcza5

Reporting a reproducible case where deepseek/deepseek-v4.1-flash stops reasoning entirely on tool-loop continuations through the Provider API.

What I see

Every request whose messages ends with a role: "tool" result comes back with usage.completion_tokens_details.reasoning_tokens == 1 and no reasoning_content on the assistant message. I hit this 31 times in a row across four batches (8 + 10 + 8 + 5). Never a value above 1.

The answer itself is fine. finish_reason is tool_calls or stop, tool calls parse normally. The model just stops thinking.

In a long agent session this is what it looks like: my message gets a normal thinking block, then the first tool call thinks, then somewhere in the tool loop it silently stops, and every turn after that produces a bare reply until I send a new user message.

What fixes it, and what doesn't

Same request body, one change at a time:

change reasoning_tokens
nothing (tail is role: "tool") 1,1,1,1,1,1,1,1
append 27 chars of text after the last tool result 64,89,78,50,51,49,59,42
append 100 chars to the last tool result's content 95,105,37,196,283,99
echo reasoning_content on the prior assistant turn 1,1,1,1,1,1,1,1
echo reasoning_content: "" 1,1,1,1,1,1,1,1
echo a placeholder string 1,1,1,1,1,1,1,1

The last three are the reason I'm opening this. #726 says the fix is "the prior turn's reasoning_content echoed on the tool-call message". I can't reproduce that. Present, empty, or placeholder - the result is identical to sending nothing.

Environment

opencode 2.3.2, opencode-cmd-provider 2.4.0, Windows 10, GOAT plan.

Request is about 56 KB: 23 KB system prompt, 13 tool schemas at 16 KB, messages ending in two tool results. stream: true, max_tokens: 64000, reasoning_effort: "max", no temperature.

What I couldn't pin down

I tried to isolate the trigger and didn't get a clean variable, so here are the things that moved the number rather than a formula.

Tool count, same body, trimming the schema array: 13 tools -> 0/8, 8 -> 2/8, 6 -> 7/8. A gradient, not a step.

max_tokens: 1024 -> 3/8, 4096 -> 1/8, 64000 -> 2/8. Suggestive, not confirmed.

What I can say is that a small request does not reproduce. With 3 tools and a short system prompt the same model reasoned normally, 8/8. Whatever this is, it needs a heavy tool-loop request to show up. That's probably why it isn't reported more: it only bites long sessions, and the visible symptom is "the reply came back fast", not an error.

Also

Two other slugs bill reasoning tokens without returning the text. deepseek-v4.1-flash charged 26-82 reasoning tokens with reasoning_content absent, 6/6. deepseek-v4-flash-fast charged 40-106, absent, 6/6. Different symptom from the above, possibly the same cause. Can file separately if you'd rather track it apart.

Related

#726 - same symptom, closed as fixed. I can't reproduce the stated fix.
#754 #829 #840 - reasoning_content dropped from history on the way up. Those are about the request; this is about the response.
#1152 - muse-ember drops reasoning on continuation turns.

I can attach the request body if it helps. It's almost entirely tool schemas and the two tool results.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions