Skip to content

<think> tags in plain string content are displayed as raw text instead of being stripped or collapsed #21515

Closed as not planned

Description

@vulcanen

Description

When using models that return thinking content as inline tags in a plain string content field ( via OpenAI-compatible API), opencode renders the raw tags and thinking content directly to the user:
{ "role": "assistant", "content": "<think>用户用中文说\"你好\",这是一个简单的问候。我应该用中文友好地回复。\n</think>\n\n你好!有什么我可以帮助你的吗?" }
Expected: Only show 你好!有什么我可以帮助你的吗? — the thinking content should be stripped or collapsed into a reasoning block.

Actual: The entire string including ... is displayed as plain text.

Context
This is related to #11439 and #18748. Many OpenAI-compatible providers use inline tags rather than structured reasoning_content fields. OpenCode should handle both formats.

Suggested Approach
At the rendering layer, parse , , tags and either:
Strip thinking content entirely, or
Display it as a collapsible reasoning block (consistent with native reasoning_content handling)
Preserve raw tags in storage so multi-turn LLM context is not broken (as noted in #11439)
Handle edge cases: unclosed tags during streaming, tags inside code blocks should be left alone

Plugins

No response

OpenCode version

1.4.0

Steps to reproduce

No response

Screenshot and/or share link

Image

Operating System

Windows 10

Terminal

No response

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 8, 2026
  2. github-actions commented on Apr 8, 2026

    @github-actions
    Contributor

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

    These issues cover the same core problem of handling inline <think> tags from OpenAI-compatible providers. Consider adding your context (especially the plain string content format and the Windows repro) as a comment on #11439 instead.

  3. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. github-actions commented on Jul 3, 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.

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