Repository navigation
Description
Description
When using LM Studio with a reasoning model (Qwen3.5-27B) where reasoning_content is separated from regular content in the API response, the OpenCode UI streaming parser prematurely terminates the response display whenever it encounters backticks (`) in either field.
The raw API stream completes successfully with proper separation (verified via curl), but the OpenCode client-side renderer cuts off at the first occurrence of a backtick character, suggesting a markdown/stream parsing issue specific to how split reasoning_content + content is rendered for non-Anthropic providers.
Note: Truncation consistently occurs near the end of responses, after most content has already streamed successfully. The response appears nearly complete before cutting off mid-sentence at a backtick boundary.
Plugins
OpenCode version
1.2.15
Steps to reproduce
- Configure LM Studio with a reasoning-capable model (e.g., Qwen3.5-27B with thinking tags)
- Enable "Separate reasoning_content and content in API responses" in LM Studio Developer settings
- In OpenCode, use the model via
@ai-sdk/openai-compatibleprovider - Trigger a response that will contain backticks (e.g., asking for code examples or explanations with markdown formatting)
- Observe the streaming output
Expected behavior: Full response streams and renders completely, including any backticks in both reasoning_content and content fields.
Actual behavior: Response cuts off immediately when either field outputs a backtick character (`). The truncation happens consistently at this boundary.
Technical Analysis
Key finding: The issue is not with:
- LM Studio's API (verified working via curl)
- Inline reasoning_content handling (that works fine)
- Anthropic/Claude providers (fixed in PR fix: prevent truncated Claude streams #6388)
- Early/mid-response streaming (only affects content near the end)
The issue appears isolated to:
- Provider:
@ai-sdk/openai-compatible(LM Studio, not Anthropic) - Content format: Responses where
reasoning_contentandcontentare separate fields in the stream - Trigger character: Backtick (`), likely also triple-backtick code blocks
- Timing: Truncation occurs near response completion, suggesting a buffer/stream termination edge case
Likely root cause: The markdown/stream renderer in OpenCode may be treating backticks as delimiter boundaries when parsing splitreasoning_content+contentstreams from OpenAI-compatible providers, causing premature termination of the display buffer. This differs from how Anthropic's separated reasoning is handled (which was fixed in fix: prevent truncated Claude streams #6388).
The fact that truncation happens near the end suggests this may be related to:
- Stream completion handling when backticks are present in final chunks
- Buffer flush/cleanup logic that doesn't properly escape markdown delimiters
- A race condition between stream termination and markdown parsing
Related Issues
- Backticks in output at premature termination at opencode responses #1475 (Closed): "Backticks in output at premature termination at opencode responses" — Similar symptom reported July 2025, appears to have been partially fixed but not for this specific scenario
- fix: prevent truncated Claude streams #6388 (Merged Dec 29, 2025): "fix: prevent truncated Claude streams" — Upgrades
@ai-sdk/anthropicto handle split reasoning_content, but does not apply to OpenAI-compatible providers like LM Studio - reasoning_content not sent when using @ai-sdk/openai-compatible with deepseek-reasoner #6040 (Closed): "reasoning_content not sent when using @ai-sdk/openai-compatible with deepseek-reasoner" — Related reasoning_content handling issue for same provider type
- Sometimes the conversation streaming just cuts off near the end (cosmetically) #5838 (Closed as duplicate): "Sometimes the conversation streaming just cuts off near the end (cosmetically)" — Similar end-of-stream truncation pattern
Screenshot and/or share link
Curl test (streaming mode) — completes successfully with proper separation:
curl -s "http://10.4.0.10:1234/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"model": "*",
"messages": [{"role": "user", "content": "Write a bash script with markdown backticks"}],
"stream": true,
"max_tokens": 4096
}' | python3 -c "import sys,json; [print(json.loads(l[6:])) for l in sys.stdin if l.startswith('data:') and not '[DONE]' in l]"Output shows reasoning_content field with thinking process (including ``` code blocks) and separate content field with the actual response. Both complete successfully. ✅
OpenCode UI behavior: Response cuts at:
...Most likely causes:
1. Stop sequences in LM Studio — Check if `
[TRUNCATED - never shows content after this point]
Even though the raw API delivers both fields completely, OpenCode's renderer stops displaying further content when backticks appear.
Operating System
macOS 26.3 (25D125)
Terminal
Warp
Activity
swilshin commentedon Apr 12, 2026
Having a near identical issue, think this is the same bug so posting here. Notable difference, I am not using LM Studio when this bug occurs.
Version: Current (1.4.3) with Big Pickle in the TUI
My Set-up:
Ubuntu 24.04.4 LTS
Gnome Terminal Version 3.52.0
No plugins
Description
The LLM output gets truncated mid-sentence shortly after the first occurrence of a backtick character (`) in the response. The truncation happens consistently at backtick boundaries.
Steps to reproduce
Expected behaviour
Complete output should be displayed with all content after backticks visible.
Actual behaviour
Output truncates shortly after the first backtick. Example:
"- Constructor/serialization: Uses `LimbMap"
(cuts off here - no continuation)
Technical notes
Other similar issues not mentioned in initial report.
savantskie commentedon Apr 19, 2026
I also am having a near identical issue, I'm sure this is the same bug so posting here. Notable difference, I amusing llama.cpp when this bug occurs.
Version: Current (1.14.17)
My Set-up:
OS: Kubuntu 22.04.5 LTS (Jammy Jellyfish) x86_64
Terminal: GNOME Terminal 3.44.0
No plugins
llama.cpp version is: version: 8620 (1d6d4cf7a)
Description
The LLM output gets truncated mid-sentence shortly after the first occurrence of a backtick character (`) in the response. The truncation happens consistently at backtick boundaries.
Steps to reproduce
Expected behaviour
Complete output should be displayed with all content after backticks visible.
Actual behaviour
Output truncates shortly after the first backtick. Example:
"- Constructor/serialization: Uses `LimbMap"
(cuts off here - no continuation)
Technical notes
xak2000 commentedon Apr 21, 2026
I'm not sure if I having the same issue, but it looks very similar. The output is often truncated near backtricks. Even with the default BigPickle model. I just start web UI (
opencode web) without any plugins and any changes from the default configuration when installed.Example of truncated output:
I'm not sure the problem is the same as usually output contains many backtricks and it is cut off not after the very first backtrick, but in the middle of the output. But it is always near some backtrick. Maybe it is a coincedence, though, as honestly any output contains many backtricks, so wherever you cut, it will be somewhere near some backtrick. :)
Update:
Actually, I noticed that in my case it is
<that often makes the output cut. In the example aboveinsertUserInterests(Collectionthe next character is obiously would be<. E.g.insertUserInterests(Collection<Interest> interests).Another example of a truncated message
const props = defineProps. Here, again, the next character definitely should have been<- it is well-known Vue construct. E.g.const props = defineProps<{ foo: boolean }>().dhaern commentedon May 8, 2026
This is still happening and is an important bug...
agent-daryl commentedon May 28, 2026
Hitting the same issue with Ollama as the OpenAI-compatible provider.
Setup:
/v1/chat/completionsendpoint@ai-sdk/openai-compatibleproviderSymptoms:
Why this affects my usage heavily: Almost every prompt involves shell commands, scripts, or configuration blocks (I use opencode primarily as an AI assistant for infrastructure/Linux administration tasks). Every backtick-rich response I get truncated.
Workaround I am using: When output truncates, I prompt with "continue" and the model generates the remainder. This works but breaks the conversation flow badly.
Not sure if this helps triage, but the original reproduction steps (LM Studio with split
reasoning_content) are similar to my setup — Ollama doesn't have the same split fields, so I'm wondering if this is really a broader@ai-sdk/openai-compatibleissue rather than specific to LM Studio + split fields.github-actions commentedon Jul 27, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.