anomalyco / anomalyco/opencode

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

Open
#43,385 0 comments 0 reactions 1 assignee View on GitHub

@fwang is already working on this.

Since Aug 19, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.