Repository navigation
Description
Summary
When using a Kimi model (e.g. cf/@cf/moonshotai/kimi-k2.6 / kimi-k2.7-code) through an OpenAI-compatible provider, the agent loop stops after the first tool call instead of continuing to the next step. A model like MiniMax M3 on the same provider works fine (read -> edit -> done).
Environment
- OpenCode: 1.17.18 (latest)
- Provider: OpenAI-compatible (@ai-sdk/openai-compatible), baseURL http://100.95.250.13:20128/v1
- Models affected: cf/@cf/moonshotai/kimi-k2.6, cf/@cf/moonshotai/kimi-k2.7-code (also nvidia/moonshotai/kimi-k2.6, cline-pass/kimi-k2.6)
- Agent: build
Reproduction (agent loop)
Task: "read alvo.py, find the bug and fix by adding the missing import".
- Model calls glob (or read).
- OpenCode returns the tool result.
- Model returns finish_reason: "stop" with no follow-up tool call -> agent ends without editing.
Observed step_finish after the tool result: reason:"stop". The model is capable of the next step (see below).
Key evidence — raw provider API works
Calling the same provider/model directly (curl) with the same multi-turn tool sequence returns a correct continuation:
- After glob result only: finish_reason:"tool_calls", model calls read.
- After glob + read results: finish_reason:"tool_calls", model calls edit_file with correct args.
So the endpoint/model is fine; the issue is in how OpenCode drives the multi-step loop for this model.
Suspected cause
Kimi returns its reasoning in a separate reasoning_content field (not interleaved in the streamed content). OpenCode appears to not continue the loop correctly when the model emits reasoning_content after a tool result, finalizing the turn early (stop) instead of executing the next tool call.
Config flags tested (no effect)
- reasoning: true / false
- interleaved: true / false
- attachment + modalities present / absent (minimal config with only name/limit/tool_call)
- Multiple provider endpoints (cf/, nvidia/, cline-pass/)
All still stop after the first tool call. MiniMax (no separate reasoning_content behavior) works in every configuration.
Expected behavior
After a tool result, the agent should continue calling tools (read -> edit) until the task is complete, as it does for MiniMax.
Minimal raw repro (works, proves endpoint OK)
POST /v1/chat/completions
{
"model": "cf/@cf/moonshotai/kimi-k2.6",
"messages": [
{"role":"system","content":"You are a coding agent."},
{"role":"user","content":"Read alvo.py and fix the missing import."},
{"role":"assistant","tool_calls":[{"id":"call_1","type":"function","function":{"name":"glob","arguments":"{"pattern":"**/alvo.py"}"}}]},
{"role":"tool","tool_call_id":"call_1","content":"/sandbox/alvo.py"}
],
"tools":[{"type":"function","function":{"name":"read","description":"Read","parameters":{"type":"object","properties":{"filePath":{"type":"string"}},"required":["filePath"]}}}],
"tool_choice":"auto"
}
Response: finish_reason:"tool_calls" -> read tool call (correct).
Activity
github-actions commentedon Jul 10, 2026
This issue might be a duplicate of existing issues. Please check:
github-actions commentedon Sep 9, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.