Skip to content

Queued user messages are serialized inconsistently across turns and break prompt caching #21518

@CoolZxp

Description

@CoolZxp

Description

When a user sends a follow-up message while the assistant is still running, OpenCode wraps that queued message in a temporary block before sending the next request to the model.
That wrapper is only applied for that in-flight turn. It is not preserved as part of the message’s stable history. On later turns, the same message is sent back to the model in its original unwrapped form.
As a result, the exact same historical user message is serialized differently across requests:

  • when first consumed from the queue: wrapped in <system-reminder>
  • on later turns: original text

This breaks prompt caching, since the prompt prefix is no longer stable across turns even though the underlying conversation history has not meaningfully changed.
The original user-visible message text should remain unchanged in the UI, but the model-facing representation of queued messages should be stable across future turns.

Plugins

None

OpenCode version

1.4.0

Steps to reproduce

  1. Start a session and send a prompt that keeps the model busy long enough to submit another message before the first run finishes.
  2. While that run is still in progress, send a second user message.
  3. Let OpenCode continue and consume that queued message.
  4. Send a third message after the queued message has already been processed.
  5. Inspect the model inputs for:
    • the request that first consumes the queued message
    • the later request that includes that same message as conversation history
  6. Notice that the queued message is wrapped with a <system-reminder> in the first request, but appears as original text in the later request.

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

Windows Terminal

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions