Repository navigation
Bug: Bedrock Mantle for GPT 5.5 can return empty successful responses, causing OpenCode to stop mid-task #31430
Description
Description
Bug: Bedrock Mantle can return empty successful responses, causing OpenCode to stop mid-task
Description
When using openai.gpt-5.5 through the @ai-sdk/amazon-bedrock/mantle provider, OpenCode can stop in the middle of an agentic task without an error. The provider intermittently returns a successful response with:
status=completedfinishReason/finishequivalent tostopoutput=[]usage.output_tokens=0- no text content
- no tool calls
OpenCode treats that as a normal assistant turn with no more work to do, so the session exits even though the task is incomplete.
This appears specific to Bedrock Mantle. I have not observed the same behavior when using the OpenAI provider with the same model and equivalent request options (reasoningEffort, reasoningSummary, include: ["reasoning.encrypted_content"], textVerbosity).
This is similar in impact to other Bedrock/Mantle issues where OpenCode stops silently after a provider-level response is technically successful but unusable, for example #14221. This issue is narrower: the response is completely empty rather than containing leaked tool-call tokens or malformed tool results.
Impact
Long-running agentic tasks become unreliable with Bedrock Mantle because a single empty successful response ends the OpenCode loop. There is no visible error, so from the user's perspective OpenCode simply stops working partway through the task.
The empty completion recovers when the same request is retried, so this looks like a transient provider response that OpenCode could safely treat as retryable.
Steps to Reproduce
- Configure
openai.gpt-5.5via@ai-sdk/amazon-bedrock/mantleusing the Bedrock OpenAI-compatible endpoint. - Run a multi-step agentic task that requires several tool-call rounds, for example cloning a repo and setting it up.
- After a few tool-call rounds, observe that the session sometimes stops even though the task is incomplete.
Minimal direct API reproducer, without OpenCode:
import json
import os
import urllib.request
token = os.environ["AWS_BEARER_TOKEN_BEDROCK"]
url = "https://bedrock-mantle.us-east-2.api.aws/openai/v1/responses"
tools = [
{
"type": "function",
"name": "run",
"description": "Run one command",
"parameters": {
"type": "object",
"properties": {"cmd": {"type": "string"}},
"required": ["cmd"],
},
}
]
def call(input_items):
payload = {
"model": "openai.gpt-5.5",
"input": input_items,
"tools": tools,
"store": False,
"reasoning": {"effort": "medium", "summary": "auto"},
"include": ["reasoning.encrypted_content"],
"max_output_tokens": 1500,
"text": {"verbosity": "low"},
}
req = urllib.request.Request(url, data=json.dumps(payload).encode(), method="POST")
req.add_header("Authorization", f"Bearer {token}")
req.add_header("Content-Type", "application/json")
with urllib.request.urlopen(req, timeout=60) as response:
return json.loads(response.read())
input_items = [
{
"role": "user",
"content": "Coding agent. Use run one cmd per turn: echo a; echo b; echo c; echo d; echo e. Continue after each result.",
}
]
for step in range(10):
body = call(input_items)
output = body.get("output", [])
output_tokens = body.get("usage", {}).get("output_tokens")
print(f"step {step}: output_tokens={output_tokens} items={[item.get('type') for item in output]}")
if output_tokens == 0 or not output:
print(" >>> EMPTY COMPLETION")
input_items += output
function_calls = [item for item in output if item.get("type") == "function_call"]
if not function_calls:
break
for function_call in function_calls:
input_items.append(
{
"type": "function_call_output",
"call_id": function_call["call_id"],
"output": "ok",
}
)In my testing, about half of the runs hit an empty completion at a random step. Example outcome: 3 of 6 sessions returned output_tokens=0 with output=[] before completing the requested tool-call sequence.
Expected Behavior
The provider should return either:
- a tool call, when the task still requires tool execution
- a text response, when the model is done
- an error, if the provider cannot produce a valid response
OpenCode should not silently stop on a zero-content successful response during an agentic loop.
Actual Behavior
Bedrock Mantle sometimes returns a successful but empty response:
status=completed
output=[]
usage.output_tokens=0
OpenCode then exits because the assistant turn has no tool calls and the finish reason is stop.
Where it happens in OpenCode
- Agent loop exit:
packages/opencode/src/session/prompt.ts:1251-1269 - Retry behavior:
packages/opencode/src/session/retry.tsretries provider/API errors, but not successful zero-content responses
Proposed Fix
Treat successful zero-content assistant responses as retryable while an agentic turn is in progress.
Specifically, before exiting on finish="stop" with no tool calls, detect whether the assistant produced any usable output. If the response has no text, no tool calls, and tokens.output === 0, retry the request up to a small bounded limit rather than ending the session.
This should be scoped narrowly so normal short text responses and legitimate task completion are unaffected. A retry is appropriate here because the same request recovers on retry in the direct API reproducer.
Related Issues
- Kimi K2.5 on AWS Bedrock: multiple failures — premature end_turn, silent stops, and toolResult format errors #14221: Kimi K2.5 on AWS Bedrock has related silent-stop behavior, though with different failure modes such as leaked tool-call tokens and toolResult format errors.
- Kimi K2.5 on Bedrock: premature end_turn due to Converse API tool call parsing bugs #13807: Bedrock provider/tool-call parsing issues with Kimi K2.5.
- Kimi K2 via AWS BEDROCK stops execution #11210: Kimi K2 via AWS Bedrock stops execution.
Environment
- OpenCode:
1.16.2 - Provider:
@ai-sdk/amazon-bedrock/mantle - Endpoint:
https://bedrock-mantle.us-east-2.api.aws/openai/v1/responses - Model:
openai.gpt-5.5 - Options:
reasoningEffort: medium,reasoningSummary: auto,textVerbosity: low,store: false,include: ["reasoning.encrypted_content"] - Comparison: the same model through
@ai-sdk/openaihas not shown this behavior in my testing
Plugins
No response
OpenCode version
1.16.2
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
Ubuntu 24.04.4 LTS
Terminal
Ghostty
Activity
github-actions commentedon Jun 8, 2026
This issue might be a duplicate of or closely related to existing issues. Please check:
bedrock kimi-k2.5 can stop with no final assistant output— same Bedrock silent-stop pattern (no content, task incomplete)Kimi K2.5 on AWS Bedrock: multiple failures — premature end_turn, silent stops— already referenced in your issue; the empty-output variant you describe may be a subset of thisDead loop: infinite empty assistant messages (tokens=0) after tool call with empty text— identical symptom of zero output_tokens / empty output from a provider during an agentic loopGPT OSS 120B subagent stops mid-reasoning and returns empty result after several tool calls— same empty-result-stops-session behaviour, different providerIf any of these cover your case, consider adding detail there rather than tracking it separately. If this is genuinely distinct (Bedrock Mantle + OpenAI-compatible endpoint specifics), please note that in a comment so maintainers can triage accordingly.
PershingSquare commentedon Jun 9, 2026
I am also getting similar issue with gpt 5.4 on bedrock
rekram1-node commentedon Jun 9, 2026
I hit this myself but it's a bedrock bug they are literally sending back empty responses ssaying that it completed its work
PershingSquare commentedon Jun 9, 2026
Codex has same issue.
openai/codex#26860
joaomj commentedon Jun 9, 2026
i built a proxy around that.
fix(opencode): stop treating an empty fault-state response as a finis…
fix(opencode): stop treating an empty fault-state response as a finis…