Skip to content

PR #25303 causes mass KV invalidation on model switch (Plan↔Build↔Compact) #32603

Description

@malventano

Description

Switching between Plan and Build modes (or using a custom compaction model) causes long delays due to vLLM prefix cache invalidation. The model must re-process the entire conversation history on each model switch.

The bug was introduced in PR #25303 ("fix: bedrock reasoning issue", May 2026) which modified packages/opencode/src/session/message-v2.ts to convert reasoning parts to text when switching models. While this fixed Bedrock signature validation errors, it broke vLLM prefix caching because the reasoning_content field is lost during the conversion.

Plan and Build modes may use different model IDs (e.g., Qwen3.6-27B-Plan vs Qwen3.6-27B-Build) as this is currently the only way to configure different sampling parameters per the model card (temperature, presence_penalty, etc.). Custom compaction models also trigger this issue. Switching models triggers the reasoning→text conversion, causing cache misses even though the underlying model may be the same.

Reasoning parts should never be converted to text, regardless of model switches. Any other model should receive the full context intact, including reasoning history. Any blanket conversion of prior chat history triggers mass KV cache invalidation.

Plugins

N/A

OpenCode version

1.17.7

Steps to reproduce

  1. Start a session in Build mode
  2. Have a conversation to build up prefix cache
  3. Switch to Plan mode (or trigger compaction with custom model)
  4. Send a message
  5. Observe long delay as vLLM re-processes history

Screenshot and/or share link

Network capture analysis shows:

  • Build mode: Assistant messages include reasoning_content field
  • Plan mode (after switch): reasoning_content field missing from assistant messages

This confirms the field is being stripped when switching modes, causing the cache miss.

Operating System

Linux

Terminal

N/A

Activity

  1. github-actions commented on Jun 16, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is distinct, please clarify how it differs from #22813 in particular.

  2. github-actions commented on Aug 16, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  3. added a commit that references this issue on Aug 17, 2026
    46ed1d2
  4. added a commit that references this issue on Sep 3, 2026
    2abdcea
  5. added a commit that references this issue on Sep 16, 2026
    1a1b3f3
  6. added a commit that references this issue on Sep 26, 2026
    5cd26b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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