anomalyco / anomalyco/opencode
Responses multi-turn fails on strict gateways: replayed reasoning items drop provider id (input.N.id: expected a value)
@rekram1-node is already working on this.
Since Sep 11, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Fresh session, first turn works (reasoning summary streams back); any second turn fails with 400 — but only against Responses gateways that strictly validate input items. Same two turns succeed against lenient upstreams.
Root cause (verified below): on turn 2, opencode replays the previous turn's typed items (type: reasoning / type: message) without the provider-side ids (rs_* / msg_*). Gateways requiring id on typed items reject the request:
Opencode failed to send message with error: Invalid value for 'input.2.id': expected a value.
Minimal repros against the gateway (POST /v1/responses, stream: true):
# reasoning item WITHOUT id -> 400, same error template as the client
{"input":[
{"role":"user","content":"hi"},
{"type":"reasoning","summary":[{"type":"summary_text","text":"..."}]},
{"type":"message","id":"msg_real123","role":"assistant","status":"completed",
"content":[{"type":"output_text","text":"hi!"}]},
{"role":"user","content":"what can you do?"}]}
# -> {"param":"input.1.id","message":"Invalid value for 'input.1.id': expected a value."}
# message item WITHOUT id -> 400 as well
{"input":[
{"role":"user","content":"hi"},
{"type":"message","role":"assistant","status":"completed",
"content":[{"type":"output_text","text":"hi!"}]},
{"role":"user","content":"why?"}]}
# -> {"message":"Invalid value for 'input.1': Responses output message status requires an item id."}
Control cases (all 200): role-based messages, typed items with id, function_call_output replays.
Related but distinct from #5104: in Dec 2025 (v1.0.133) the replay carried id + encrypted_content and died on crypto verification; now it carries no id and dies on id validation. Lenient upstreams accept the id-less replay, which is likely why this went unnoticed.
Possible fixes (maintainer's call): preserve provider item ids when round-tripping typed items, skip replaying id-less/empty reasoning items, or put it behind an option.
Provider/model config (keys redacted; same failure via two different baseURLs with identical model options, so it's not gateway-specific):
"experientiallabs": {
"npm": "@ai-sdk/openai",
"name": "ExperientialLabs Direct",
"options": {
"baseURL": "https://api.experientiallabs.ai/v1",
"apiKey": "<redacted>"
},
"models": {
"gpt-5.6-luna": {
"name": "GPT-5.6 Luna",
"modalities": { "input": ["text", "image"], "output": ["text"] },
"options": {
"reasoningEffort": "max",
"reasoningSummary": "detailed",
"include": ["reasoning.encrypted_content"],
"maxTokens": 32000
},
"variants": {
"max": { "reasoningEffort": "max", "reasoningSummary": "detailed", "include": ["reasoning.encrypted_content"] },
"xhigh": { "reasoningEffort": "xhigh", "reasoningSummary": "detailed", "include": ["reasoning.encrypted_content"] },
"high": { "reasoningEffort": "high", "reasoningSummary": "detailed", "include": ["reasoning.encrypted_content"] },
"medium": { "reasoningEffort": "medium", "reasoningSummary": "detailed", "include": ["reasoning.encrypted_content"] },
"low": { "reasoningEffort": "low", "reasoningSummary": "detailed", "include": ["reasoning.encrypted_content"] }
},
"limit": { "context": 256000, "input": 224000, "output": 32000 }
}
}
}
Plugins
opencode-mem
OpenCode version
1.18.30 (running inside OpenChamber)
Steps to reproduce
- Point
@ai-sdk/openaiat any strict Responses gateway (reasoningSummary: detailedso turn 1 yields a reasoning item). - New session, send
hi→ works. - Send a second message →
Invalid value for 'input.2.id': expected a value.(see screenshot). - Same two turns against a lenient upstream → both succeed.
Screenshot and/or share link
Screenshot attached below (turn 1 streams reasoning summary + answer; turn 2 errors; bottom bar shows the direct-gateway model in use).
Operating System
Windows 11 (WSL backend)
Terminal
OpenChamber desktop v1.22.2 (hosting opencode web UI)
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.