Error making calls to OpenAI reasoning models #558

Closed
opened 2026-02-16 17:27:18 -05:00 by yindo · 32 comments
Owner

Originally created by @ike-grl on GitHub (Jul 8, 2025).

Originally assigned to: @thdxr on GitHub.

I just tried to set up opencode for the first time and I can't get it initialized in a repo unfortunately. I am using OpenAI (since I have a dev key provided through work) with the model @openai/codex-mini-latest.

Here's the error that comes from calling /init.

$ opencode run /init --print-logs

ERROR 2025-07-08T16:34:39 +196ms service=session error=AI_APICallError: Item 'rs_686d488fcb4081a08df0417fa4dd718b0a5d60fd71eba6e4' of type 'reasoning' was provided without its required following item.

From what I see in the developer docs for reasoning model calls for OAI, the type for reasoning has subsequent items like so:

Originally created by @ike-grl on GitHub (Jul 8, 2025). Originally assigned to: @thdxr on GitHub. I just tried to set up opencode for the first time and I can't get it initialized in a repo unfortunately. I am using OpenAI (since I have a dev key provided through work) with the model `@openai/codex-mini-latest`. Here's the error that comes from calling `/init`. ``` $ opencode run /init --print-logs ERROR 2025-07-08T16:34:39 +196ms service=session error=AI_APICallError: Item 'rs_686d488fcb4081a08df0417fa4dd718b0a5d60fd71eba6e4' of type 'reasoning' was provided without its required following item. ``` From what I see in the developer docs for reasoning model calls for OAI, the `type` for reasoning has subsequent items like so: - [response.reasoning.done](https://platform.openai.com/docs/api-reference/responses-streaming/response/reasoning/done) - [response.reasoning.delta](https://platform.openai.com/docs/api-reference/responses-streaming/response/reasoning/delta)
yindo closed this issue 2026-02-16 17:27:18 -05:00
Author
Owner

@garymjr commented on GitHub (Jul 8, 2025):

I just experienced this same error

@garymjr commented on GitHub (Jul 8, 2025): I just experienced this same error
Author
Owner

@rekram1-node commented on GitHub (Jul 8, 2025):

related: https://github.com/vercel/ai/issues/7099

@rekram1-node commented on GitHub (Jul 8, 2025): related: https://github.com/vercel/ai/issues/7099
Author
Owner

@garymjr commented on GitHub (Jul 9, 2025):

It looks like this might have been fixed in vercel/ai#7167

This seems unrelated to the linked issue unfortunately.

@garymjr commented on GitHub (Jul 9, 2025): ~It looks like this might have been fixed in [vercel/ai#7167](https://github.com/vercel/ai/pull/7167)~ This seems unrelated to the linked issue unfortunately.
Author
Owner

@ike-grl commented on GitHub (Jul 10, 2025):

@garymjr any idea when this will get merged to opencode? I just ran opencode upgrade and it's still erroring.

@ike-grl commented on GitHub (Jul 10, 2025): @garymjr any idea when this will get merged to opencode? I just ran `opencode upgrade` and it's still erroring.
Author
Owner

@garymjr commented on GitHub (Jul 10, 2025):

I tried overriding the sdk that was being loaded with the latest one from @ai-sdk/openai, but I'm still seeing the reasoning error. I'm not sure why those issues were marked as related.

@garymjr commented on GitHub (Jul 10, 2025): I tried overriding the sdk that was being loaded with the latest one from [@ai-sdk/openai](https://github.com/vercel/ai/releases/tag/%40ai-sdk%2Fopenai%402.0.0-beta.6), but I'm still seeing the reasoning error. I'm not sure why those issues were marked as related.
Author
Owner

@andreimaxim commented on GitHub (Jul 11, 2025):

Same error with o3 and opencode v0.2.27.

@andreimaxim commented on GitHub (Jul 11, 2025): Same error with o3 and opencode v0.2.27.
Author
Owner

@garymjr commented on GitHub (Jul 11, 2025):

Adding a check to only include reasoning messages that contain summary text fixes the reasoning error, but then the model starts running into issues calling tools, so I'm concerned there's more to it than just filtering out the reasoning messages.

https://github.com/garymjr/ai/blob/gm/openai-reasoning/packages/openai/src/responses/convert-to-openai-responses-messages.ts#L168-L178

@garymjr commented on GitHub (Jul 11, 2025): Adding a check to only include reasoning messages that contain summary text fixes the reasoning error, but then the model starts running into issues calling tools, so I'm concerned there's more to it than just filtering out the reasoning messages. https://github.com/garymjr/ai/blob/gm/openai-reasoning/packages/openai/src/responses/convert-to-openai-responses-messages.ts#L168-L178
Author
Owner

@ike-grl commented on GitHub (Jul 14, 2025):

Curious if anyone has found a workaround for this? Still not working as of 0.3.3.

@ike-grl commented on GitHub (Jul 14, 2025): Curious if anyone has found a workaround for this? Still not working as of `0.3.3`.
Author
Owner

@rekram1-node commented on GitHub (Jul 14, 2025):

Vercel AI sdk maintainer said on the linked issue they believe they located the issue and it will ship tmr

@rekram1-node commented on GitHub (Jul 14, 2025): Vercel AI sdk maintainer said on the linked issue they believe they located the issue and it will ship tmr
Author
Owner

@JovanVeljanoski commented on GitHub (Jul 15, 2025):

Same problem but for google/gemini-2.5-pro and google/gemini-2.5-flash (i have not tried others).
Version 0.3.8

@JovanVeljanoski commented on GitHub (Jul 15, 2025): Same problem but for `google/gemini-2.5-pro` and `google/gemini-2.5-flash` (i have not tried others). Version `0.3.8`
Author
Owner

@thdxr commented on GitHub (Jul 15, 2025):

updated ai sdk in v0.3.9 try and see if it works now?

@thdxr commented on GitHub (Jul 15, 2025): updated ai sdk in v0.3.9 try and see if it works now?
Author
Owner

@thesofakillers commented on GitHub (Jul 15, 2025):

seems to work for me now after the latest update (v0.3.9). Succesfully queried codex-mini

@thesofakillers commented on GitHub (Jul 15, 2025): seems to work for me now after the latest update (v0.3.9). Succesfully queried codex-mini
Author
Owner

@Medard-prog commented on GitHub (Jul 15, 2025):

issue is still there, v0.3.9

Image Image
@Medard-prog commented on GitHub (Jul 15, 2025): issue is still there, v0.3.9 <img width="711" height="276" alt="Image" src="https://github.com/user-attachments/assets/922e512b-05d6-4608-8a7e-cfa005208898" /> <img width="501" height="37" alt="Image" src="https://github.com/user-attachments/assets/31ae30db-0068-4dd1-844e-54801133c086" />
Author
Owner

@garymjr commented on GitHub (Jul 15, 2025):

also still seeing this with v0.3.9

@garymjr commented on GitHub (Jul 15, 2025): also still seeing this with v0.3.9
Author
Owner

@ike-grl commented on GitHub (Jul 15, 2025):

Also seeing this Issue in 0.3.9

@ike-grl commented on GitHub (Jul 15, 2025): Also seeing this Issue in 0.3.9
Author
Owner

@Medard-prog commented on GitHub (Jul 15, 2025):

has anyone managed to find a temporary work-around?

@Medard-prog commented on GitHub (Jul 15, 2025): has anyone managed to find a temporary work-around?
Author
Owner

@ike-grl commented on GitHub (Jul 15, 2025):

@Medard-prog I have not heard of any other workarounds unfortunately

@ike-grl commented on GitHub (Jul 15, 2025): @Medard-prog I have not heard of any other workarounds unfortunately
Author
Owner

@thdxr commented on GitHub (Jul 16, 2025):

can you clear ~/.cache/opencode and see if it's there

@thdxr commented on GitHub (Jul 16, 2025): can you clear \~/.cache/opencode and see if it's there
Author
Owner

@JohnBakhmat commented on GitHub (Jul 16, 2025):

v0.3.15, Arch btw, still doesn't work after deleting ~/.cache/opencode

Image
@JohnBakhmat commented on GitHub (Jul 16, 2025): v0.3.15, Arch btw, still doesn't work after deleting ~/.cache/opencode <img width="1465" height="566" alt="Image" src="https://github.com/user-attachments/assets/dc7f8e65-54e4-40cf-8d41-08d184f641e5" />
Author
Owner

@ike-grl commented on GitHub (Jul 16, 2025):

I have to same issue with openai/codex-mini-latest on version 0.3.16 after clearing the ~/.cache/opencode. On Mac BTW.

@ike-grl commented on GitHub (Jul 16, 2025): I have to same issue with `openai/codex-mini-latest` on version `0.3.16` after clearing the `~/.cache/opencode`. On Mac BTW.
Author
Owner

@garymjr commented on GitHub (Jul 16, 2025):

vercel/ai#7099 was re-opened and a new patch was added. Might need to version bump to the latest ai beta.

@garymjr commented on GitHub (Jul 16, 2025): [vercel/ai#7099](https://github.com/vercel/ai/issues/7099) was re-opened and a new patch was added. Might need to version bump to the latest ai beta.
Author
Owner

@Medard-prog commented on GitHub (Jul 16, 2025):

can we do that manually?

@Medard-prog commented on GitHub (Jul 16, 2025): can we do that manually?
Author
Owner

@rekram1-node commented on GitHub (Jul 16, 2025):

I think they fixed it in one of their latest releases, tested locally can't replicate error anymore. Made a PR with version bump

@rekram1-node commented on GitHub (Jul 16, 2025): I think they fixed it in one of their latest releases, tested locally can't replicate error anymore. Made a PR with version bump
Author
Owner

@Medard-prog commented on GitHub (Jul 16, 2025):

Still happening as of v0.3.17

@Medard-prog commented on GitHub (Jul 16, 2025): Still happening as of v0.3.17
Author
Owner

@rekram1-node commented on GitHub (Jul 16, 2025):

Yo @Medard-prog your supabase access token is visible it may not be a secret but just letting u know if it is

@rekram1-node commented on GitHub (Jul 16, 2025): Yo @Medard-prog your supabase access token is visible it may not be a secret but just letting u know if it is
Author
Owner

@rekram1-node commented on GitHub (Jul 16, 2025):

Also there hasn't been a release since my PR got merged so once the next release goes out lmk if you still run into the issue.

@rekram1-node commented on GitHub (Jul 16, 2025): Also there hasn't been a release since my PR got merged so once the next release goes out lmk if you still run into the issue.
Author
Owner

@JustinKasad commented on GitHub (Jul 16, 2025):

@thdxr would be great to get this in a release soon! I'm seeing the same issue when running /init

Thank you!

@JustinKasad commented on GitHub (Jul 16, 2025): @thdxr would be great to get this in a release soon! I'm seeing the same issue when running `/init` Thank you!
Author
Owner

@garymjr commented on GitHub (Jul 16, 2025):

I built this from source, but codex-mini frequently stops responding. I haven't tried other reasoning models yet. I tested o3 and it seems to be working. Codex mini and o4 mini seem to both struggle.

@garymjr commented on GitHub (Jul 16, 2025): I built this from source, but codex-mini frequently stops responding. ~I haven't tried other reasoning models yet.~ I tested o3 and it seems to be working. Codex mini and o4 mini seem to both struggle.
Author
Owner

@Medard-prog commented on GitHub (Jul 17, 2025):

Yo @Medard-prog your supabase access token is visible it may not be a secret but just letting u know if it is

you're right, I'm going to reset it, thank you haha!

@Medard-prog commented on GitHub (Jul 17, 2025): > Yo [@Medard-prog](https://github.com/Medard-prog) your supabase access token is visible it may not be a secret but just letting u know if it is you're right, I'm going to reset it, thank you haha!
Author
Owner

@garymjr commented on GitHub (Jul 17, 2025):

Image

Adding the beast prompt to codex and o4 seems to prevent the stopping. I did notice that it seems to reference files in a way that opencode isn't parsing correctly.

@garymjr commented on GitHub (Jul 17, 2025): <img width="866" height="311" alt="Image" src="https://github.com/user-attachments/assets/84aafdff-498b-4aa5-966b-87ece146a7af" /> Adding the beast prompt to codex and o4 seems to prevent the stopping. I did notice that it seems to reference files in a way that opencode isn't parsing correctly.
Author
Owner

@Medard-prog commented on GitHub (Jul 19, 2025):

Hey! Does it still happen for anyone else?

Image
@Medard-prog commented on GitHub (Jul 19, 2025): Hey! Does it still happen for anyone else? <img width="1417" height="744" alt="Image" src="https://github.com/user-attachments/assets/f07d301d-8904-4f8f-900e-304a5e3148ba" />
Author
Owner

@rekram1-node commented on GitHub (Jul 19, 2025):

@Medard-prog idk for me it works just fine...

Maybe try clearing: ~/.cache/opencode

@rekram1-node commented on GitHub (Jul 19, 2025): @Medard-prog idk for me it works just fine... Maybe try clearing: ~/.cache/opencode
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#558