OpenCode.ai's parsing system appears to rely on the <|tool_calls_section_end|> token to properly delimit tool calling sections, but this token is frequently missing, malformed, or incorrectly handled by various AI models, leading to parsing failures and broken tool execution.
Environment
- Provider: OpenRouter
- Model: moonshotai/kimi-k2
- OS: Linux
Issue Description
The <|tool_calls_section_end|> token appears to be critical for OpenCode.ai's response parsing, but many models fail to generate it consistently, causing:
- Incomplete tool execution
- Parsing errors
- System hanging/time out issues
- Malformed responses
Steps to Reproduce
- Configure OpenCode with Kimi K2 through OpenRouter:
{
"model": "moonshotai/kimi-k2",
"provider": "openrouter"
}
- Request a task that requires tool calls (e.g., "Create a file named test.py")
- Observe the raw response output (if possible)
- Note missing or malformed
<|tool_calls_section_end|> token
Expected Behaviour
- All models should consistently generate the required section end token
- Parser should handle missing tokens gracefully
- Tool execution should work regardless of minor token variations
OpenCode.ai's parsing system appears to rely on the
<|tool_calls_section_end|>token to properly delimit tool calling sections, but this token is frequently missing, malformed, or incorrectly handled by various AI models, leading to parsing failures and broken tool execution.Environment
Issue Description
The
<|tool_calls_section_end|>token appears to be critical for OpenCode.ai's response parsing, but many models fail to generate it consistently, causing:Steps to Reproduce
{ "model": "moonshotai/kimi-k2", "provider": "openrouter" }<|tool_calls_section_end|>tokenExpected Behaviour