anomalyco / anomalyco/opencode
MiMo V2.5 outputs tml:function_calls as plain text instead of structured tool calls
@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
- Select
opencode-go/mimo-v2.5as the model - Send a prompt that triggers tool use (e.g., run a command, edit a file)
- Observe that the agent outputs
tml:function_callsas 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-deltaevents accumulate the XML content- No
tool-callevents are ever emitted by the provider/SDK - On
step-finish, the finish reason isstop(nottool-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-resultevents - 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:
- packages/opencode/src/session/processor.ts - in the
text-endorstep-finishhandler - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.