Skip to content

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

Description

@bbartels

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 af332a2 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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions