anomalyco / anomalyco/opencode

core: standalone signed-empty reasoning turns are replayed into later requests

Open
#46,881 5 comments 0 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Sep 2, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

V2 replays completed assistant turns whose only content is empty reasoning plus provider metadata.
In packages/core/src/session/runner/to-llm-message.ts, same-model reasoning retains provider metadata, and the meaningful filter considers metadata sufficient even when part.text === "". The existing omits empty assistant turns test explicitly preserves a standalone { text: "", state: { signature } } turn.
The Amazon Bedrock adapter serializes each retained part as:
{
"reasoningContent": {
"reasoningText": {
"text": "",
"signature": "..."
}
}
}
Controlled forks isolated the effect:

  • The exact prompt with the clean full history (~620k provider tokens) produced visible text and tools.
  • The same prompt with one or two standalone signed-empty turns still worked.
  • The same prompt with five accumulated signed-empty turns deterministically returned another signature-only end_turn with no visible output.
  • Manual compaction repaired the session because compaction rendering drops empty reasoning parts.
    Expected: signed reasoning state is retained when it accompanies semantic assistant output—text, readable reasoning, or a tool call—but a standalone metadata-only assistant turn is omitted from future model history or marked failed by the no-output handling described separately.
    Actual: state-only turns accumulate and can poison subsequent same-model requests.
Plugins

No response

OpenCode version

opencode2 v0.0.0-dev-18900; current V2 source af332a2363 remains affected.

Steps to reproduce
  1. Create a V2 session using a provider that returns signed reasoning metadata.
  2. Persist several completed assistant turns containing only reasoning.text = "" and a provider signature.
  3. Submit a prompt that works in a fork before those turns.
  4. Observe the provider request replay each empty reasoningText plus signature.
  5. Observe the later response repeat the signature-only pattern.
  6. Compact the same session and retry; the prompt works because the empty reasoning turns are no longer replayed.
Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.