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?
|
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:
|
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?
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
And here is the explicit line in
MessageV2.toModelMessagethat includes reasoning blocks:opencode/packages/opencode/src/session/message-v2.ts
Lines 537 to 544 in ddd9c71
Is this how it is supposed to work?
Or do providers like Anthropic filter these out on their end?