Skip to content

Local Ollama subagents return tool calls as text instead of executing them in task/delegate #21181

Closed as not planned

Description

@JuanEstrada

Description

Local Ollama subagents do not execute tool calls in task or delegate.
Instead of executing the tool and continuing the loop, OpenCode returns the tool call itself as text or pseudo-tool output. This causes false success and no real filesystem side effects.
I reproduced this with local subagents using Ollama models in WSL with the Ollama server running on Windows. Direct filesystem operations outside subagents work correctly, and direct calls to Ollama’s OpenAI-compatible API can return proper tool calls, so the issue appears to be in OpenCode’s local subagent runtime/tool execution path.

Custom global configuration with local SDD subagents and skill-registry workflow. No extra third-party runtime plugin beyond @opencode-ai/plugin.

Plugins

No response

OpenCode version

1.3.16

Steps to reproduce

  1. Configure a local Ollama provider in OpenCode using @ai-sdk/openai-compatible.
  2. Create or use a local subagent with file tools enabled (bash, read, edit, write) and permissions allowed.
  3. Invoke the subagent through task or delegate and ask it to:
    • create a file with write, or
    • run pwd with bash
  4. Observe that the subagent returns a tool call payload or pseudo-tool output as text instead of executing it.
  5. Verify that the expected file does not exist and no real side effect happened.

Screenshot and/or share link

Image Image Image

Operating System

WSL on Windows 11 (Ollama server running on Windows host)

Terminal

NuShell in WSL

Activity

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

    @github-actions
    Contributor

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

  3. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. HIK-506 commented on May 31, 2026

    @HIK-506

    I can reproduce a very similar issue with OpenCode + local Ollama over the OpenAI-compatible endpoint.

    Summary

    OpenCode appears to claim that it wrote a file successfully, but the expected file is not created in the project directory. In my case, the model/tool flow looks successful in the chat, but there is no real filesystem side effect in the current working directory.

    This is especially confusing because direct Ollama API tests return proper structured tool_calls, so the model and Ollama endpoint seem capable of tool calling. The issue seems to happen somewhere in the OpenCode runtime/tool execution path, or possibly around the working directory used for file tools.

    Environment

    • Client machine: Windows 10
    • OpenCode running from PowerShell
    • Project directory: C:\Users\Light\Downloads\Test
    • Ollama server: remote Linux machine on LAN
    • Ollama endpoint used by OpenCode: http://192.168.1.92:11434/v1
    • Ollama server OS: TUXEDO OS / Ubuntu-Debian based Linux
    • GPU: NVIDIA GTX 1050 3 GB Max-Q
    • RAM: 16 GB
    • Provider config: @ai-sdk/openai-compatible

    Models tested

    Models that failed / produced fake or non-executed tool calls

    • qwen2.5-coder variants through Ollama
    • hhao/qwen2.5-coder-tools:3b
    • hhao/qwen2.5-coder-tools:1.5b

    With these models, tool calls were often printed as JSON-like text instead of being executed.

    Models that passed direct Ollama API tool-call tests

    • huihui_ai/qwen3-abliterated:4b, aliased as qwen3-ablit-4b-tools-8k
    • huihui_ai/qwen3-abliterated:1.7b, aliased as qwen3-ablit-1_7b-tools-4k

    Direct API test against Ollama /v1/chat/completions returned proper structured tool calls:

    "content": "",
    "tool_calls": [
      {
        "type": "function",
        "function": {
          "name": "write",
          "arguments": "{\"filePath\":\"index.html\",\"content\":\"...\"}"
        }
      }
    ],
    "finish_reason": "tool_calls"

    So Ollama and the model can return real tool calls.

    OpenCode behavior

    Prompt used inside OpenCode:

    Create a real file named index.html in the current directory using the write tool. Put a basic HTML page inside it with the title "Test". Do not print JSON. Do not print HTML. After writing the file, reply only: created index.html
    

    OpenCode displayed something like:

    # Wrote index.html
    <!DOCTYPE html>
    <html lang="en">
    ...
    </html>
    

    Then it produced a summary saying the file was successfully written:

    Progress
    Done
    - Wrote file successfully.
    
    Relevant Files
    - index.html: Created with the basic HTML structure and title "Test".
    

    But after exiting/checking PowerShell:

    cd C:\Users\Light\Downloads\Test
    Test-Path .\index.html

    Result:

    False
    

    So the expected file was not created in the project directory.

    A recursive search found an index.html under:

    C:\Users\Light\.config\opencode\index.html
    

    That suggests the file may be written in OpenCode’s config directory instead of the project working directory, or the tool execution context is not the same as the TUI/project directory.

    Additional symptom

    After the apparent write, OpenCode entered repeated thinking/compaction/build cycles, even though the task was supposedly done:

    Compaction -> Build -> Compaction -> Build
    

    It kept summarizing that the file was created, but the expected project file still did not exist.

    Expected behavior

    If OpenCode says it used the write tool to create index.html, the file should exist in the current project directory:

    C:\Users\Light\Downloads\Test\index.html
    

    Actual behavior

    OpenCode claims success, but:

    Test-Path C:\Users\Light\Downloads\Test\index.html

    returns:

    False
    

    A file may instead appear under:

    C:\Users\Light\.config\opencode\index.html
    

    Why I think this is an OpenCode-side issue

    Direct Ollama API calls return proper structured tool_calls with the same model. The model is not merely printing JSON in that case. But inside OpenCode, the write operation either does not execute in the expected directory or reports false success.

    This looks related to local Ollama/OpenAI-compatible tool execution, working-directory handling, or compaction/tool-result handling inside OpenCode.

    I can provide full logs/config if useful.

  5. github-actions commented on Jul 31, 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