Repository navigation
Kimi K2.5 on AWS Bedrock: multiple failures — premature end_turn, silent stops, and toolResult format errors #14221
Description
Description
Kimi K2.5 (moonshotai.kimi-k2.5) is effectively unusable when accessed through Amazon Bedrock as the provider. The model exhibits multiple interrelated failure modes that prevent it from completing agentic tasks, while the same model works correctly through other providers (e.g., OpenCode Zen, OpenRouter, Moonshot AI direct).
Failure 1: Premature end_turn after 2–3 tool calls
The model issues a stop / end_turn finish reason after only 2–3 tool calls, even when the task clearly requires more. This forces users to repeatedly re-invoke opencode run or manually prompt "continue" to complete tasks that other providers handle in a single session.
Root cause: Bedrock's Converse API has known tool call parsing bugs for Moonshot/Kimi models. Internal model tokens (<|tool_call_begin|>, <|tool_call_end|>, <|tool_call_argument_begin|>) intermittently leak into text output instead of being parsed as proper tool calls. When this happens, the AI SDK sees a text response + end_turn instead of tool_use, causing the agentic loop to exit. This is confirmed upstream at vercel/ai#11409.
Failure 2: Session stops silently with no error
In some cases the model simply stops responding mid-task. The last message in the exported session shows a "finish": "stop" with very low output token count (e.g., 58 tokens), and the reasoning block contains raw tool call tokens that were never parsed:
{
"type": "reasoning",
"text": " Now let me check the api POST handler: <|tool_calls_section_begin|> <|tool_call_begin|> tooluse_Vbs57l9NT6-Lu5tgQRwYjA{\"filePath\": \"/app/...\"} <|tool_call_end|> <|tool_calls_section_end|>"
}The tool call was embedded in the reasoning/thinking text rather than being extracted as a proper tool use block, so OpenCode sees a completed response with no pending actions and stops.
Failure 3: toolResult JSON format validation errors
During longer sessions with multiple tool calls, Bedrock rejects tool result payloads:
error: The format of the value at messages.N.content.0.toolResult.content.0.json is invalid.
Provide a json object for the field and try again.
This is a known Bedrock Converse API limitation documented in aws/aws-sdk-js-v3#7330 — Bedrock requires tool results to be valid JSON objects, but some OpenCode tool results (e.g., file writes, empty responses) may not meet this requirement. This crashes the session entirely.
Why this is an OpenCode issue (not just upstream)
While these bugs originate in the Bedrock Converse API / AI SDK layer, OpenCode should consider mitigations:
- Route Kimi/Moonshot models through Bedrock's OpenAI-compatible endpoint (
bedrock-mantle.<region>.api.aws/v1) instead of the Converse API. Testing confirms this completely eliminates the premature stopping issue (see Kimi K2.5 on Bedrock: premature end_turn due to Converse API tool call parsing bugs #13807 for validation data). - Wrap non-JSON tool results in a JSON object before sending to Bedrock, similar to how other Bedrock-compatible tools handle this edge case.
- Add retry/continuation logic when a Bedrock response shows tool call tokens leaked in text output, indicating a failed tool call parse.
- Document the known limitation and recommend alternative providers for Kimi K2.5 until Bedrock fixes their Converse API for Moonshot models.
Related issues
- Kimi K2.5 on Bedrock: premature end_turn due to Converse API tool call parsing bugs #13807 — Kimi K2.5 on Bedrock: premature end_turn due to Converse API tool call parsing bugs (detailed root cause analysis + validated fix using OpenAI-compatible endpoint)
- Kimi K2 via AWS BEDROCK stops execution #11210 — Kimi K2 via AWS Bedrock stops execution (multiple user confirmations of silent stops)
- Amazon Bedrock Kimi2 Thinking output #5630 — Amazon Bedrock Kimi2 Thinking output (tool call tokens leaking into text)
- toolResults sent to AWS/Bedrock models rejected for missing json subdocument #11035 — toolResults sent to AWS/Bedrock models rejected for missing json subdocument
- Improper processing of a Bedrock error message causes failures. #13040 — Improper processing of a Bedrock error message causes failures
- vercel/ai#11409 — Upstream AI SDK issue confirming Bedrock Converse API tool call parsing bugs for Kimi models
Comparison with other providers
| Provider | Tool calls per session | Completes full task? | Notes |
|---|---|---|---|
| Amazon Bedrock (Converse API) | 2–3 then end_turn |
No | Requires multiple manual re-invocations |
| Bedrock OpenAI-compatible endpoint | 8+ | Yes | Works correctly |
OpenCode Zen (kimi-k2.5) |
14+ | Yes | Works correctly |
| Moonshot AI direct | 10+ | Yes | Works correctly |
| OpenRouter | 10+ | Yes | Works correctly |
Plugins
None (default configuration)
OpenCode version
v1.2.6 (latest stable)
Steps to reproduce
-
Configure AWS Bedrock provider:
{ "$schema": "https://opencode.ai/config.json", "model": "amazon-bedrock/moonshotai.kimi-k2.5", "provider": { "amazon-bedrock": { "options": { "region": "us-east-1" } } } } -
Ensure you have Bedrock access for
moonshotai.kimi-k2.5in us-east-1. -
Run a multi-step task:
opencode run "Create a simple REST API with Flask: set up the project, write CRUD endpoints, add tests, run the tests, and show results" -
Expected: The model chains 8+ tool calls and completes the full task in a single session.
-
Actual: One or more of the following occurs:
- Model stops after 2–3 tool calls with
end_turn, requiring manual re-invocation - Session silently stops with raw
<|tool_call_begin|>tokens visible in reasoning output - Session crashes with
toolResult.content.0.json is invaliderror
- Model stops after 2–3 tool calls with
Screenshot and/or share link
N/A — reproducible with the steps above
Operating System
macOS
Terminal
Various (issue is provider-level, not terminal-dependent)
Activity
github-actions commentedon Feb 19, 2026
This issue might be a duplicate of (or closely overlaps with) several existing open issues. Please check:
This issue aggregates the same problems already tracked individually above. Consider whether a new issue adds value beyond what is already tracked, or if it would be better to add your findings (especially the OpenAI-compatible endpoint workaround) as comments on the existing issues — particularly #13807.
CashWilliams commentedon Feb 19, 2026
This is a bedrock issue not an opencode one. I've tested direct to bedrock and 50% of calls fail.
Thijmen commentedon Apr 8, 2026
@CashWilliams have you opened a case with AWS for this? Or anyone?
Out of interest, how've you tested this and concluded with 50% of calls fails?
stephenthedev commentedon Apr 24, 2026
Using the converse endpoint, and Bedrocks latest deployment this is working for me! Try again folks!
github-actions commentedon Jul 4, 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.