Repository navigation
Description
Description
On v2.2.5, sending any message to affected existing sessions fails in both TUI and WebUI:
Duplicate item found with id . Remove duplicate items from your input and try again.
New sessions work. The affected history contains legacy reasoning parts such as:
{"type":"reasoning","text":"...","state":{"reasoningField":"reasoning"}}Replaying these parts produces multiple Responses reasoning input items without an id. The upstream rejects them as duplicate empty identifiers.
Environment
- OpenCode: v2.2.5
- OS: Linux / WSL2
- Clients: TUI and WebUI
- Provider adapter:
@opencode/ai/providers/openai-compatible-responses
Reproduction
- Resume a session containing at least two reasoning parts in the legacy shape above.
- Send a message through the Responses adapter to an upstream that rejects multiple id-less reasoning items.
- The request fails with the error above; subsequent messages encounter the same history and fail again.
The repository bot's reproduction uses an isolated session and local mock endpoint. It reports the same behavior on v2.2.5 and dev (7864a94), and captures two reasoning items with neither id nor encrypted_content. Its script seeds the legacy shape; it does not establish how that shape was originally produced.
Evidence and scope
Direct probes against the affected upstream, with a user message included and store: false:
| Reasoning input | Result |
|---|---|
| One item without an id | 200 |
| Two items without ids | 400, duplicate empty id |
| Two items with distinct ids | 200 |
The rejection depends on the upstream, but OpenCode's history replay produces the id-less items. This warrants investigating legacy-history replay handling, rather than treating provider switching as the complete solution. It does not establish a defect in all Responses implementations.
The legacy state field is still read as provider metadata, according to the reproduction. Missing ids do not by themselves prove metadata loss or a missing migration; the original writer version and cause remain unverified. Duplicate-id and encrypted-content errors are outside this report's reproduced scope.
Expected behavior
Handle this legacy history with a provider-appropriate replay or recovery path instead of repeatedly sending input the upstream rejects. Preserve valid reasoning metadata and encrypted content; synthetic ids accepted by this upstream are not a general fix for other providers.
Activity
opencodejr commentedon Nov 4, 2026
Thanks for the detailed report. I reproduced this on v2.2.5, and it still happens on the latest
dev(7864a94).What I did:
@opencode/ai/providers/openai-compatible-responses, pointed at a local mock/v1/responsesserver. The mock rejects requests that contain more than one reasoning item without an id, as your upstream does.{"type":"reasoning","text":"...","state":{"reasoningField":"reasoning"}}, noitemId).Duplicate item found with id . Remove duplicate items from your input and try again.The captured request contained two
{"type":"reasoning","summary":[...]}input items, with noidand noencrypted_content. The oldstatefield is read back as provider metadata, so the Responses request builder still sends these parts even though they have no item id. Your workaround of writing unique ids into the stored parts addresses the same root cause.The script below reproduces it: it starts the mock server, edits the session database and runs both turns. Related: #55357 and its PR #56879 cover reasoning ids dropped when they aren't shaped like
rs_…. That is a different case from ids that are missing entirely.Reproduction script (repro.sh)
Run it:
bash repro.sh[-]session: history with id-less reasoning parts bricks every message with "Duplicate item found with id ."[/-][+]session: legacy reasoning replay fails with "Duplicate item found with id ."[/+]56wj commentedon Nov 4, 2026
I traced this to
packages/ai/src/protocols/open-responses.ts:lowerReasoningcan serialize a persisted reasoning part when provider metadata exists but itsitemIdis absent. I am preparing a focused fix that skips unreplayable id-less reasoning parts and adds regression coverage.