Skip to content

MiMo V2.5 outputs tml:function_calls as plain text instead of structured tool calls #43385

Closed as not planned

Description

@push-rush

MiMo V2.5 outputs tml:function_calls as plain text instead of structured tool calls

Description

When using MiMo V2.5 (via opencode-go/mimo-v2.5), the model occasionally outputs XML-like function call syntax as plain text instead of using the structured OpenAI tool_calls API format. The malformed output looks like:

<tml:function_calls>
<invoke name="bash">
<parameter name="command">some-command</parameter>
</invoke>
</tml:function_calls>

Since this arrives as text-delta event (not a structured tool_call event), the processor treats it as the final response text, the step finishes with reason stop (not tool-calls), and the agent loop terminates, halting execution mid-task.

Steps to Reproduce

  1. Select opencode-go/mimo-v2.5 as the model
  2. Send a prompt that triggers tool use (e.g., run a command, edit a file)
  3. Observe that the agent outputs tml:function_calls as rendered text and stops executing

Expected Behavior

The model tool call output should be parsed and dispatched as structured tool calls, allowing execution to continue.

Root Cause Analysis

The opencode runtime exclusively handles OpenAI-style structured tool_calls (SSE delta.tool_calls[].function.{name,arguments}). There is no text-based fallback parser for models that output XML-like function call syntax as plain text.

When MiMo outputs tml:function_calls as text:

  • text-delta events accumulate the XML content
  • No tool-call events are ever emitted by the provider/SDK
  • On step-finish, the finish reason is stop (not tool-calls)
  • The agent loop decides to stop, ending execution

Key code paths involved:

  • packages/llm/src/protocols/utils/tool-stream.ts - only parses structured SSE tool_calls
  • packages/opencode/src/session/processor.ts - only handles tool-call/tool-result events
  • packages/opencode/src/session/llm/ai-sdk.ts - toLLMEvents() only forwards structured tool calls

Suggested Fix

Add text-based XML function call detection as a fallback in the processor or LLM event pipeline. When the step finishes with reason stop but the accumulated text contains XML-like function call patterns (<function_calls>, <invoke name=...>, etc.), parse the text and emit synthetic tool-call events to allow execution to continue.

Possible implementation locations:

  1. packages/opencode/src/session/processor.ts - in the text-end or step-finish handler
  2. packages/opencode/src/session/llm/ai-sdk.ts - in toLLMEvents(), intercept text events

Environment

  • opencode version: 1.18.18 (npm)
  • Model: opencode-go/mimo-v2.5
  • OS: Windows 11
  • Terminal: PowerShell

Additional Context

This may be related to #43185 (mimo-v2.5 tool calls fail with invalid tool calls) and #42923 (mimo-v2.5 stuck in infinite thinking loop), as all three stem from MiMo tool call format being incompatible with opencode expectations. The tml: prefix in tml:function_calls appears to be a model-specific XML namespace or tokenizer artifact.

Activity

  1. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    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 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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