You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
Tool execution aborted/terminated — occurs with local LM Studio models. Agent freezes prematurely during tool execution, requires manual "continue" to proceed.
Steps to reproduce:
Run opencode with LM Studio provider
Use Qwen3.6-35b-A3B or similar local model
Execute task with tool calls (bash, read, edit)
Tool execution aborts after ~30-60 seconds
Expected behavior:
Tool execution should complete without manual intervention.
This issue might be a duplicate of existing issues. Please check:
Tool execution aborted #25577: Same symptom — tool execution aborted mid-task, requires manual "continue" to proceed
If this is a distinct issue (e.g., specific to local LM Studio models vs. cloud Claude models), please add clarifying details about what makes it different. Otherwise, consider adding your information to the existing issue.
Also note #17307 which covers aggressive timeouts with local models, which may be related to your use case.
v1.14.48 Desktop, checking the logs it seems like there's a timeout happening in Undici. Anyway we can change this? I have slow inference but it will produce results after thinking for some time but the 5 minute timeout has caused me nothing but problems. Probably gonna downgrade to 1.14.41 CLI or something. Also using a local network for my API.
On the desktop, this problem has not been solved yet. But in CLI Works fine
on the latest version. If you need an interface, I recommend the latest
version in the command line with the launch command - opencode Web.
Андрей.
пн, 11 мая 2026 г., 18:04 Jumpman ***@***.***>:
Issue: Tool execution aborted prematurely with local models (LM Studio / @ai-sdk/openai-compatible)
Describe the bug
When using a local model via LM Studio (@ai-sdk/openai-compatible), tool execution (bash, file operations) gets aborted mid-execution. The agent returns Tool execution aborted or Tool execution terminated by the model, resulting in broken sessions.
To Reproduce
Configure LM Studio as provider with @ai-sdk/openai-compatible
Use any local model (tested with qwen3.6-35b-a3b)
Ask the agent to execute a tool that takes more than ~250ms (e.g., git log, npm install, file search)
Tool gets aborted mid-execution
Root cause (from source code analysis)
The issue is in packages/opencode/src/session/processor.ts — the cleanup() function:
constcleanup=(deadline: number)=>Effect.gen(function*(){// ...yield*Effect.all(tools,{concurrency: "unbounded"}).pipe(Effect.timeout("250 millis"),)// Any tool still pending after 250ms gets marked as "Tool execution aborted"for(consttooloftools){if(/* still pending */){yield*tool.fail(`Tool execution aborted: using "${result.model}"`)}}})
The 250ms timeout is too aggressive. For local models, tool execution often exceeds this window, causing premature cancellation.
A contributing factor is in packages/opencode/src/session/llm.ts — Stream.scoped creates an AbortController that calls ctrl.abort() when the stream scope closes. If the scope closes while tools are still in-flight (between LLM call iterations), the abort signal propagates through the AI SDK and terminates tool execution.
Additional context: packages/core/src/tool/bash.ts sets DEFAULT_TIMEOUT_MS = 120000 (2 minutes), showing the expected tool lifecycle is much longer than 250ms.
Expected behavior
Tools should be allowed to complete their execution before cleanup, or given a reasonable timeout (matching the tool's configured timeout, e.g., 120s for bash). The 250ms window should be either:
Removed (let tools finish naturally)
Increased to match tool-level timeouts (60-120s)
Made configurable via provider/model options
Environment
OpenCode version: 1.17.9 (prebuilt binary, npm global install)
OS: Windows 11
Provider: LM Studio 0.3.13 (@ai-sdk/openai-compatible)
Yeah, doing my project causes terminated error. would be handy to apply bandage to write "Terminated: Seems like you doing lot of work, wait 5 minutes and then continue." instead just "terminated"
I tried also with the free models on opencode, and other providers.
I think that is something like waiting the model respond with the whole function tool and that the agent parse that but changing the various timeout didn't fixed.
After checking the logs, I found two root causes leading to task interruption:
Initial request timeout issue: I added the config provider:{"options":{"timeout":6000,"headerTimeout":false,"chunkTimeout":60000}} to adjust timeout parameters, which fixed the link timeout errors.
Git compatibility issue: The old Git version did not support the --sparse flag and broke the clone process. I upgraded Git to a newer compatible version.
Both issues have been resolved by configuring the timeout options and updating Git, and the workflow runs smoothly now.
The tool execution freezing mid-way with local LM Studio models is a known pain point. The agent appears to hang because there's no heartbeat/timeout mechanism between the frontend and the local model server.
A pattern that works in production:
Timeout + restart pipeline — Set a hard timeout on each tool call (e.g., 120s). If the call exceeds the timeout, automatically terminate the stuck call and restart from the last checkpoint. This prevents the agent from freezing indefinitely.
Dead-man's switch — Periodically the agent must emit a progress signal. If 3 consecutive heartbeats are missed, assume the tool call is hung and auto-restart.
Graceful model fallback — If the local model keeps freezing, auto-failover to an API-based model for that specific call, then resume with local model on the next call.
I built a free diagnostic tool that can scan agent configs for these reliability gaps (timeouts, fallback chains, stuck detection): ark-6ek.pages.dev/diagnose
30s, no signup.
After updating to v1.18.20, the hard abort (UnknownError: terminated) is gone — but the new retry behavior introduced a different problem on long sessions with local models:
What happens now:
During a long session, the provider response ends with finish_reason: network_error (or similar)
Instead of aborting, opencode retries the entire request
The model restarts its reasoning from scratch — all thinking progress is lost
Prompt cache is preserved, so the replay is faster than a cold start, but the model still re-generates the full reasoning chain
Impact on local models (LM Studio):
Reasoning chains can take minutes; losing them on every network hiccup makes long sessions impractical
The retry is transparent (no visible error), so the user just sees the agent "thinking again" — easy to miss that progress was reset
Suggestion: consider resuming from the last stable state (e.g., keep completed tool results and only regenerate the interrupted step) instead of replaying the full turn, or make the retry budget/configurable for slow local providers.
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.
Activity
github-actions commentedon May 6, 2026
This issue might be a duplicate of existing issues. Please check:
If this is a distinct issue (e.g., specific to local LM Studio models vs. cloud Claude models), please add clarifying details about what makes it different. Otherwise, consider adding your information to the existing issue.
Also note #17307 which covers aggressive timeouts with local models, which may be related to your use case.
aagarin39 commentedon May 7, 2026
aagarin39 commentedon May 7, 2026
aagarin39 commentedon May 8, 2026
Long recording is also stopped. In general, the problem with all expectations when working with local llm systems.
aagarin39 commentedon May 8, 2026
2026-05-08 12:59:47 [INFO]
[qwen3.6-35b-a3b] Prompt processing progress: 100.0%
2026-05-08 13:05:13 [INFO]
[LM STUDIO SERVER] Client disconnected. Stopping generation... (If the model is busy processing the prompt, it will finish first.)
2026-05-08 13:05:13 [INFO]
[qwen3.6-35b-a3b] Finished streaming response
aagarin39 commentedon May 8, 2026
With each update, this limit of 5 minutes always appears. any update with a large volume of changes will incur a five-minute limit for local LLMs.
mironoff2007 commentedon May 9, 2026
1.14.41 same problem, using desktop version and 27B or 35B
1.14.19 cli works fine
aagarin39 commentedon May 9, 2026
yu-zou commentedon May 9, 2026
Same problem on v1.14.41
JumpmanSr commentedon May 11, 2026
v1.14.48 Desktop, checking the logs it seems like there's a timeout happening in Undici. Anyway we can change this? I have slow inference but it will produce results after thinking for some time but the 5 minute timeout has caused me nothing but problems. Probably gonna downgrade to 1.14.41 CLI or something. Also using a local network for my API.
aagarin39 commentedon May 11, 2026
Jinxatron commentedon May 14, 2026
Yeupp, running on desktop, keep getting this on heavy context processing on local model.
akmi1975 commentedon May 16, 2026
a similar problem in opencode version 1.15.1
mezenin commentedon May 31, 2026
Same at 1.15.13
5 remaining items
aagarin39 commentedon Jun 22, 2026
2026-06-22 11:02:49 [INFO]
[qwen3.6] Streaming response...
2026-06-22 11:02:50 [INFO]
[qwen3.6] Prompt processing progress: 0.0%
2026-06-22 11:03:08 [INFO]
[qwen3.6] Prompt processing progress: 2.0%
2026-06-22 11:03:24 [INFO]
[qwen3.6] Prompt processing progress: 4.0%
2026-06-22 11:03:40 [INFO]
[qwen3.6] Prompt processing progress: 6.0%
2026-06-22 11:03:56 [INFO]
[qwen3.6] Prompt processing progress: 8.0%
2026-06-22 11:04:16 [INFO]
[qwen3.6] Prompt processing progress: 10.0%
2026-06-22 11:04:34 [INFO]
[qwen3.6] Prompt processing progress: 12.0%
2026-06-22 11:04:49 [INFO]
[qwen3.6] Prompt processing progress: 14.0%
2026-06-22 11:05:06 [INFO]
[qwen3.6] Prompt processing progress: 16.0%
2026-06-22 11:05:22 [INFO]
[qwen3.6] Prompt processing progress: 18.0%
2026-06-22 11:05:37 [INFO]
[qwen3.6] Prompt processing progress: 20.0%
2026-06-22 11:05:53 [INFO]
[qwen3.6] Prompt processing progress: 22.1%
2026-06-22 11:06:10 [INFO]
[qwen3.6] Prompt processing progress: 24.1%
2026-06-22 11:06:27 [INFO]
[qwen3.6] Prompt processing progress: 26.1%
2026-06-22 11:06:46 [INFO]
[qwen3.6] Prompt processing progress: 28.1%
2026-06-22 11:07:04 [INFO]
[qwen3.6] Prompt processing progress: 30.1%
2026-06-22 11:07:21 [INFO]
[qwen3.6] Prompt processing progress: 32.1%
2026-06-22 11:07:39 [INFO]
[qwen3.6] Prompt processing progress: 34.1%
2026-06-22 11:07:53 [INFO]
[LM STUDIO SERVER] Client disconnected. Stopping generation... (If the model is busy processing the prompt, it will finish first.)
2026-06-22 11:07:53 [INFO]
[qwen3.6] Prompt processing progress: 34.1%
2026-06-22 11:07:53 [INFO]
[qwen3.6] Finished streaming response
aagarin39 commentedon Jun 22, 2026
Issue: Tool execution aborted prematurely with local models (LM Studio / @ai-sdk/openai-compatible)
Describe the bug
When using a local model via LM Studio (
@ai-sdk/openai-compatible), tool execution (bash, file operations) gets aborted mid-execution. The agent returnsTool execution abortedorTool execution terminated by the model, resulting in broken sessions.To Reproduce
@ai-sdk/openai-compatibleqwen3.6-35b-a3b)git log,npm install, file search)Root cause (from source code analysis)
The issue is in
packages/opencode/src/session/processor.ts— thecleanup()function:The 250ms timeout is too aggressive. For local models, tool execution often exceeds this window, causing premature cancellation.
A contributing factor is in
packages/opencode/src/session/llm.ts—Stream.scopedcreates anAbortControllerthat callsctrl.abort()when the stream scope closes. If the scope closes while tools are still in-flight (between LLM call iterations), the abort signal propagates through the AI SDK and terminates tool execution.Additional context:
packages/core/src/tool/bash.tssetsDEFAULT_TIMEOUT_MS = 120000(2 minutes), showing the expected tool lifecycle is much longer than 250ms.Expected behavior
Tools should be allowed to complete their execution before cleanup, or given a reasonable timeout (matching the tool's configured timeout, e.g., 120s for bash). The 250ms window should be either:
Environment
@ai-sdk/openai-compatible)Related issues
400 Bad Requestwith local vLLM (Qwen 3 XML Tools) #16488 — same bug, vLLM provider, open since March 7timeout/chunkTimeoutworkaround (did not help)Suggested fix location
packages/opencode/src/session/processor.ts:cleanup()— increase or remove the 250msEffect.timeoutpackages/opencode/src/session/llm.ts— decoupleAbortControllerlifecycle from stream scope to avoid aborting in-flight tool executionAchwaqKhalid commentedon Jun 25, 2026
As of v1.17.11 still no fix.
Unamelable commentedon Jun 26, 2026
Yeah, doing my project causes terminated error. would be handy to apply bandage to write "Terminated: Seems like you doing lot of work, wait 5 minutes and then continue." instead just "terminated"
Mte90 commentedon Jul 1, 2026
I have that issue since various releases on linux...
Mte90 commentedon Jul 1, 2026
this script patches the linux version with a different timeout, I see that now takes more in "preparing edit" but fails anyway
harikiran-lab commentedon Jul 1, 2026
It seems to be an issue on LMStudio. I switched to Unsloth inference and it resolved write file turnication issue.
Mte90 commentedon Jul 1, 2026
I tried also with the free models on opencode, and other providers.
I think that is something like waiting the model respond with the whole function tool and that the agent parse that but changing the various timeout didn't fixed.
Mte90 commentedon Jul 2, 2026
I invested all the day do try and test with a session where I always this error also on resume #34952
Huojunning commentedon Jul 8, 2026
我查阅日志后定位到两个任务中断的根源问题:
初始请求超时问题:通过新增配置 provider:{"options":{"timeout":6000,"headerTimeout":false,"chunkTimeout":60000}} 调整超时参数,解决了链路超时报错;
Git 版本兼容问题:旧版 Git 不支持--sparse稀疏克隆参数,执行拉取流程时直接中断,升级 Git 版本后兼容该参数。
目前已完成超时参数配置调整与 Git 版本升级,两处问题均修复,流程运行正常。
After checking the logs, I found two root causes leading to task interruption:
Initial request timeout issue: I added the config provider:{"options":{"timeout":6000,"headerTimeout":false,"chunkTimeout":60000}} to adjust timeout parameters, which fixed the link timeout errors.
Git compatibility issue: The old Git version did not support the --sparse flag and broke the clone process. I upgraded Git to a newer compatible version.
Both issues have been resolved by configuring the timeout options and updating Git, and the workflow runs smoothly now.
PowerfulShell commentedon Jul 12, 2026
exactly, i had this issue too, latest version
wzg0911 commentedon Jul 12, 2026
The tool execution freezing mid-way with local LM Studio models is a known pain point. The agent appears to hang because there's no heartbeat/timeout mechanism between the frontend and the local model server.
A pattern that works in production:
Timeout + restart pipeline — Set a hard timeout on each tool call (e.g., 120s). If the call exceeds the timeout, automatically terminate the stuck call and restart from the last checkpoint. This prevents the agent from freezing indefinitely.
Dead-man's switch — Periodically the agent must emit a progress signal. If 3 consecutive heartbeats are missed, assume the tool call is hung and auto-restart.
Graceful model fallback — If the local model keeps freezing, auto-failover to an API-based model for that specific call, then resume with local model on the next call.
I built a free diagnostic tool that can scan agent configs for these reliability gaps (timeouts, fallback chains, stuck detection): ark-6ek.pages.dev/diagnose
30s, no signup.
aagarin39 commentedon Aug 21, 2026
Follow-up on v1.18.20 behavior change:
After updating to v1.18.20, the hard abort (UnknownError: terminated) is gone — but the new retry behavior introduced a different problem on long sessions with local models:
What happens now:
During a long session, the provider response ends with finish_reason: network_error (or similar)
Instead of aborting, opencode retries the entire request
The model restarts its reasoning from scratch — all thinking progress is lost
Prompt cache is preserved, so the replay is faster than a cold start, but the model still re-generates the full reasoning chain
Impact on local models (LM Studio):
Reasoning chains can take minutes; losing them on every network hiccup makes long sessions impractical
The retry is transparent (no visible error), so the user just sees the agent "thinking again" — easy to miss that progress was reset
Suggestion: consider resuming from the last stable state (e.g., keep completed tool results and only regenerate the interrupted step) instead of replaying the full turn, or make the retry budget/configurable for slow local providers.
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊