Repository navigation
Description
Question
So I was under the impression that thinking blocks were ephemeral. That older thinking blocks are not used to generate a new response.
But I don't see any sort of "pruning" happening in the OpenCode code, so it seems as if the entire conversation with all the reasoning blocks gets sent back all the time?
Here's where the conversation gets made, right?
opencode/packages/opencode/src/session/prompt.ts
Lines 591 to 610 in ddd9c71
| const result = await processor.process({ | |
| user: lastUser, | |
| agent, | |
| abort, | |
| sessionID, | |
| system: [...(await SystemPrompt.environment()), ...(await SystemPrompt.custom())], | |
| messages: [ | |
| ...MessageV2.toModelMessage(sessionMessages), | |
| ...(isLastStep | |
| ? [ | |
| { | |
| role: "assistant" as const, | |
| content: MAX_STEPS, | |
| }, | |
| ] | |
| : []), | |
| ], | |
| tools, | |
| model, | |
| }) |
And here is the explicit line in MessageV2.toModelMessage that includes reasoning blocks:
opencode/packages/opencode/src/session/message-v2.ts
Lines 537 to 544 in ddd9c71
| if (part.type === "reasoning") { | |
| assistantMessage.parts.push({ | |
| type: "reasoning", | |
| text: part.text, | |
| providerMetadata: part.metadata, | |
| }) | |
| } | |
| } |
Is this how it is supposed to work?
Or do providers like Anthropic filter these out on their end?
Activity
github-actions commentedon Jan 13, 2026
This issue might be a duplicate of existing issues. Please check:
thinkingorredacted_thinkingbut foundtool_use#8010: Expectedthinkingorredacted_thinkingbut foundtool_use- related issue about thinking blocks being sent with Claude models with extended thinking enabledFeel free to ignore if none of these address your specific case.
skerit commentedon Jan 13, 2026
I don't think those existing issues match this question.
Issue #5577 is most interesting here, it seems as if it would be most logical to filter out thinking blocks in this file:
opencode/packages/opencode/src/provider/transform.ts
Line 19 in ddd9c71
But as far as I understand it, it does not.
skerit commentedon Jan 16, 2026
To be clear: I'm not asking if its wrong or forbidden to keep all previous thinking blocks in the conversation all the time, I'm asking if this is optimal use of the context.
Anthropic's documentation says:
pruneMessages({ reasoning: 'before-last-message' })specifically for thisskerit commentedon Jan 16, 2026
Alright, so I dove a bit deeper into the extended-thinking docs:
https://platform.claude.com/docs/en/build-with-claude/extended-thinking
I found some important notes here:
"Preserving thinking blocks"
"Understanding thinking block caching behavior"
"Thinking block context removal"
Model difference:
So I guess this is official Anthropic documentation confirming:
github-actions commentedon Mar 26, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.