AI_APICallError occurs after running Opencode with Azure GPT-5 Codex and GPT-5 for several minutes #2012

Closed
opened 2026-02-16 17:33:43 -05:00 by yindo · 25 comments
Owner

Originally created by @Quanta-Naut on GitHub (Oct 8, 2025).

Originally assigned to: @thdxr on GitHub.

The bug
After starting Opencode with the Ai Foundry Azure GPT-5 Codex and GPT-5 model, the application works as expected initially. However, after running it for a few minutes, the following error appears:

AI_APICallError: Item 'fc_0dc4d92ad113352f0068e68182f9c0819783624eeb74dcfc0e' of type 'function_call' was provided without its required 'reasoning' item:
'rs_0dc4d92ad113352f0068e68182ada481978281511f6e4248d4'.

Configuration: I tried this fix, but nothing changed

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "azure": {
      "models": {
        "gpt-5-codex": {
          "id": "gpt-5-codex",
          "name": "Azure GPT-5 Codex",
          "reasoning": false 
        }
      }
    }
  }
}

Even when I don't have the above config, I get the error.

Steps to Reproduce

  1. Start Opencode with the Ai Foundry Azure GPT-5 Codex model.
  2. Run it for a few minutes.
  3. Observe the error output above.

Expected behavior
Opencode should continue running without encountering this error.

Additional Information

  • The error appears only after several minutes of runtime, not immediately.
  • Please investigate why this error occurs after successful initial execution and how to resolve it.
Originally created by @Quanta-Naut on GitHub (Oct 8, 2025). Originally assigned to: @thdxr on GitHub. **The bug** After starting Opencode with the Ai Foundry Azure GPT-5 Codex and GPT-5 model, the application works as expected initially. However, after running it for a few minutes, the following error appears: ``` AI_APICallError: Item 'fc_0dc4d92ad113352f0068e68182f9c0819783624eeb74dcfc0e' of type 'function_call' was provided without its required 'reasoning' item: 'rs_0dc4d92ad113352f0068e68182ada481978281511f6e4248d4'. ``` **Configuration: I tried this fix, but nothing changed** ``` { "$schema": "https://opencode.ai/config.json", "provider": { "azure": { "models": { "gpt-5-codex": { "id": "gpt-5-codex", "name": "Azure GPT-5 Codex", "reasoning": false } } } } } ``` Even when I don't have the above config, I get the error. **Steps to Reproduce** 1. Start Opencode with the Ai Foundry Azure GPT-5 Codex model. 2. Run it for a few minutes. 3. Observe the error output above. **Expected behavior** Opencode should continue running without encountering this error. **Additional Information** - The error appears only after several minutes of runtime, not immediately. - Please investigate why this error occurs after successful initial execution and how to resolve it.
yindo closed this issue 2026-02-16 17:33:43 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 8, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #2941: Very similar error with GPT-5-codex showing "AI_APICallError: Item 'rs_... of type 'reasoning' was provided without its required following item" - same pattern of reasoning items being required but missing
  • #2966: AI_APICallError with GPT-5-codex in Zero Data Retention organizations, also related to reasoning items not being persisted
  • #3035: Related issue about reasoning traces confusing models when switching between reasoning and non-reasoning models

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 8, 2025): This issue might be a duplicate of existing issues. Please check: - #2941: Very similar error with GPT-5-codex showing "AI_APICallError: Item 'rs_... of type 'reasoning' was provided without its required following item" - same pattern of reasoning items being required but missing - #2966: AI_APICallError with GPT-5-codex in Zero Data Retention organizations, also related to reasoning items not being persisted - #3035: Related issue about reasoning traces confusing models when switching between reasoning and non-reasoning models Feel free to ignore if none of these address your specific case.
Author
Owner

@patrafter1999 commented on GitHub (Oct 8, 2025):

I have the same issue. This happens with and without the tool in ./.opencode/tool/mytool.ts

AI_APICallError: litellm.BadRequestError: AzureException BadRequestError - {
  "error": {
    "message": "Missing required parameter: 'tools[0].name'.",
    "type": "invalid_request_error",
    "param": "tools[0].name",
    "code": "missing_required_parameter"
  }
}. Received Model Group=gpt-5-codex
Available Model Group Fallbacks=None
@patrafter1999 commented on GitHub (Oct 8, 2025): I have the same issue. This happens with and without the tool in ./.opencode/tool/mytool.ts ``` AI_APICallError: litellm.BadRequestError: AzureException BadRequestError - { "error": { "message": "Missing required parameter: 'tools[0].name'.", "type": "invalid_request_error", "param": "tools[0].name", "code": "missing_required_parameter" } }. Received Model Group=gpt-5-codex Available Model Group Fallbacks=None ```
Author
Owner

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

@patrafter1999 you said same error but that’s an entirely different error?

@rekram1-node commented on GitHub (Oct 8, 2025): @patrafter1999 you said same error but that’s an entirely different error?
Author
Owner

@Quanta-Naut commented on GitHub (Oct 9, 2025):

@rekram1-node any notable solutions that work, or any workarounds available??

@Quanta-Naut commented on GitHub (Oct 9, 2025): @rekram1-node any notable solutions that work, or any workarounds available??
Author
Owner

@rekram1-node commented on GitHub (Oct 9, 2025):

@Quanta-Naut lemme do an azure deployment to test, i cant replicate w/ the other providers
ill try to get back to u on this tmr (2am where i am rn)

@rekram1-node commented on GitHub (Oct 9, 2025): @Quanta-Naut lemme do an azure deployment to test, i cant replicate w/ the other providers ill try to get back to u on this tmr (2am where i am rn)
Author
Owner

@rekram1-node commented on GitHub (Oct 9, 2025):

and this is on latest right? or at least some v0.14.xxx right?

@rekram1-node commented on GitHub (Oct 9, 2025): and this is on latest right? or at least some v0.14.xxx right?
Author
Owner

@Quanta-Naut commented on GitHub (Oct 9, 2025):

@rekram1-node Yes this is on the latest.

@Quanta-Naut commented on GitHub (Oct 9, 2025): @rekram1-node Yes this is on the latest.
Author
Owner

@sheldonhull commented on GitHub (Oct 17, 2025):

I ran into this today as well

@sheldonhull commented on GitHub (Oct 17, 2025): I ran into this today as well
Author
Owner

@rekram1-node commented on GitHub (Oct 17, 2025):

@sheldonhull are you on 0.15.7? Also are you also using azure?

@rekram1-node commented on GitHub (Oct 17, 2025): @sheldonhull are you on 0.15.7? Also are you also using azure?
Author
Owner

@jaccoh commented on GitHub (Oct 19, 2025):

I get this issue with Codex as well.. so it not entirely an opencode issue I'm afraid. Although it would be good to have a work-around as it makes it totally unusable.

@jaccoh commented on GitHub (Oct 19, 2025): I get this issue with Codex as well.. so it not entirely an opencode issue I'm afraid. Although it would be good to have a work-around as it makes it totally unusable.
Author
Owner

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

@jaccoh can you show me your opencode config? This has to do with reasoning metadata being dropped or missing, maybe your config would help me figure it out

@rekram1-node commented on GitHub (Oct 19, 2025): @jaccoh can you show me your opencode config? This has to do with reasoning metadata being dropped or missing, maybe your config would help me figure it out
Author
Owner

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

@jaccoh are you exportng it as toml? What's this?
[projects."/Users/jhoeve/PycharmProjects/bank_transactions_importer"]
trust_level = "trusted"

I don't think you shared your opencode.json?

@rekram1-node commented on GitHub (Oct 19, 2025): @jaccoh are you exportng it as toml? What's this? [projects."/Users/jhoeve/PycharmProjects/bank_transactions_importer"] trust_level = "trusted" I don't think you shared your opencode.json?
Author
Owner

@jaccoh commented on GitHub (Oct 19, 2025):

@jaccoh are you exportng it as toml? What's this? [projects."/Users/jhoeve/PycharmProjects/bank_transactions_importer"] trust_level = "trusted"

I don't think you shared your opencode.json?

oops :)

{
 "$schema": "https://opencode.ai/config.json",
  "provider": {
    "azure": {
      "models": {
        "gpt-5-codex": {
          "options": {
            "reasoningEffort": "high",
            "textVerbosity": "low",
            "reasoningSummary": "auto",
            "include": ["reasoning.encrypted_content"],
          }
        }
      }
    }
  }
}
@jaccoh commented on GitHub (Oct 19, 2025): > [@jaccoh](https://github.com/jaccoh) are you exportng it as toml? What's this? [projects."/Users/jhoeve/PycharmProjects/bank_transactions_importer"] trust_level = "trusted" > > I don't think you shared your opencode.json? oops :) ``` { "$schema": "https://opencode.ai/config.json", "provider": { "azure": { "models": { "gpt-5-codex": { "options": { "reasoningEffort": "high", "textVerbosity": "low", "reasoningSummary": "auto", "include": ["reasoning.encrypted_content"], } } } } } } ```
Author
Owner

@adeperio commented on GitHub (Oct 20, 2025):

Hi @rekram1-node I get a similar error with all the gpt-5 models at the moment.

AI_APICallError: Item 'msg_0288ca1a50a0201e0068f16f8334d881968df03cba2706156d' of type 'message' was provided without its required 'reasoning' item:
'rs_0288ca1a50a0201e0068f16f7c85448196996ec857642b076b'.

I simplified my opencode.json to this:

{
    "$schema": "https://opencode.ai/config.json",
    "instructions": [
        "CLAUDE.md"
    ],
    "autoupdate": true,
    "mcp": {
        "firecrawl": {
            "type": "local",
            "command": [
                "npx",
                "-y",
                "firecrawl-mcp"
            ],
            "enabled": true,
            "environment": {
                "FIRECRAWL_API_KEY": "xxx"
            }
        },
        "sequential-thinking": {
            "type": "local",
            "command": [
                "npx",
                "-y",
                "@modelcontextprotocol/server-sequential-thinking"
            ],
            "enabled": true
        }
    }
}

Any idea what might be happening?

I'm on 0.15.8

@adeperio commented on GitHub (Oct 20, 2025): Hi @rekram1-node I get a similar error with all the gpt-5 models at the moment. AI_APICallError: Item 'msg_0288ca1a50a0201e0068f16f8334d881968df03cba2706156d' of type 'message' was provided without its required 'reasoning' item: 'rs_0288ca1a50a0201e0068f16f7c85448196996ec857642b076b'. I simplified my opencode.json to this: ``` { "$schema": "https://opencode.ai/config.json", "instructions": [ "CLAUDE.md" ], "autoupdate": true, "mcp": { "firecrawl": { "type": "local", "command": [ "npx", "-y", "firecrawl-mcp" ], "enabled": true, "environment": { "FIRECRAWL_API_KEY": "xxx" } }, "sequential-thinking": { "type": "local", "command": [ "npx", "-y", "@modelcontextprotocol/server-sequential-thinking" ], "enabled": true } } } ``` Any idea what might be happening? I'm on 0.15.8
Author
Owner

@jaccoh commented on GitHub (Oct 20, 2025):

IMHO the error is clear.. apparently answers can sometimes not contain reasoning and open code fails on it

@jaccoh commented on GitHub (Oct 20, 2025): IMHO the error is clear.. apparently answers can sometimes not contain reasoning and open code fails on it
Author
Owner

@rekram1-node commented on GitHub (Oct 20, 2025):

is this happening no matter what you send or does it only happen if you do an abort mid convo

@rekram1-node commented on GitHub (Oct 20, 2025): is this happening no matter what you send or does it only happen if you do an abort mid convo
Author
Owner

@adeperio commented on GitHub (Oct 20, 2025):

Hi @rekram1-node it happens no matter what I send. I have had to switch off openai models.

@adeperio commented on GitHub (Oct 20, 2025): Hi @rekram1-node it happens no matter what I send. I have had to switch off openai models.
Author
Owner

@rekram1-node commented on GitHub (Oct 21, 2025):

should be fixed in next release if you set this in your opencode.json:

{
  "azure": {
      "env": [
        "AZURE_API"
      ],
      "models": {
        "gpt-5-codex": {
          "name": "GPT-5-codex",
          "options": {
            "parallelToolCalls": false, # or "store": false
          }
        }
      }
    }
}

Thank u @zWingz

@rekram1-node commented on GitHub (Oct 21, 2025): should be fixed in next release if you set this in your opencode.json: ``` { "azure": { "env": [ "AZURE_API" ], "models": { "gpt-5-codex": { "name": "GPT-5-codex", "options": { "parallelToolCalls": false, # or "store": false } } } } } ``` Thank u @zWingz
Author
Owner

@adeperio commented on GitHub (Oct 21, 2025):

Awesome thanks @rekram1-node that worked

  "provider": {
    "openai": {
      "models": {
        "gpt-5-codex": {
          "id": "gpt-5-codex",
          "name": "GPT-5 Codex",
          "options": {
            "reasoningEffort": "medium",
            "textVerbosity": "low",
            "parallelToolCalls": false
          }
        },
        "gpt-5-mini": {
          "id": "gpt-5-mini",
          "name": "GPT-5 Mini",
          "options": {
            "reasoningEffort": "medium",
            "textVerbosity": "low",
            "parallelToolCalls": false
          }
        }
      }
    }
  },
@adeperio commented on GitHub (Oct 21, 2025): Awesome thanks @rekram1-node that worked ``` "provider": { "openai": { "models": { "gpt-5-codex": { "id": "gpt-5-codex", "name": "GPT-5 Codex", "options": { "reasoningEffort": "medium", "textVerbosity": "low", "parallelToolCalls": false } }, "gpt-5-mini": { "id": "gpt-5-mini", "name": "GPT-5 Mini", "options": { "reasoningEffort": "medium", "textVerbosity": "low", "parallelToolCalls": false } } } } }, ```
Author
Owner

@rekram1-node commented on GitHub (Oct 21, 2025):

ill release it tmr so we can fix azure, I will also look into "store": false and if we can use it a default and the tradeoffs so we can prevent this error going forward

@rekram1-node commented on GitHub (Oct 21, 2025): ill release it tmr so we can fix azure, I will also look into "store": false and if we can use it a default and the tradeoffs so we can prevent this error going forward
Author
Owner

@adeperio commented on GitHub (Oct 21, 2025):

Mine actually worked without tomorrow's release. I did upgrade to 0.15.10, but changed my config to the one I supplied. (I think my issue is slightly different as I'm not using azure) My error message was also "of type 'message'" instead of "of type 'function_call'"

@adeperio commented on GitHub (Oct 21, 2025): Mine actually worked without tomorrow's release. I did upgrade to 0.15.10, but changed my config to the one I supplied. (I think my issue is slightly different as I'm not using azure) My error message was also "of type 'message'" instead of "of type 'function_call'"
Author
Owner

@rekram1-node commented on GitHub (Oct 21, 2025):

u were using openai so that will work, but for azure it wont (yet) until i release, thats what my previous message meant to say

@rekram1-node commented on GitHub (Oct 21, 2025): u were using openai so that will work, but for azure it wont (yet) until i release, thats what my previous message meant to say
Author
Owner

@adeperio commented on GitHub (Oct 21, 2025):

Ahh understood. Thanks!

@adeperio commented on GitHub (Oct 21, 2025): Ahh understood. Thanks!
Author
Owner

@jaccoh commented on GitHub (Oct 21, 2025):

Is it the .10 I need to test?

@jaccoh commented on GitHub (Oct 21, 2025): Is it the .10 I need to test?
Author
Owner

@rekram1-node commented on GitHub (Oct 21, 2025):

i will release today it will be 0.15.11

Edit: released

@rekram1-node commented on GitHub (Oct 21, 2025): i will release today it will be 0.15.11 Edit: released
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2012