-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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?