Skip to content

Does OpenCode send back all previous reasoning blocks to Claude (or any provider)? #8185

@skerit

Description

@skerit

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?

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