Azure OpenAI: TypeError: Cannot use 'in' operator to search for 'tool_calls' in undefined

Resolved 💬 3 comments Opened May 22, 2025 by lazorfuzz Closed Aug 7, 2025

What version of Codex is running?

0.1.2505172129

Which model were you using?

o3

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

Using Azure OpenAI with the o3 model crashes after the first input and first response.
Consistently crashing with this error after the first input:
TypeError: Cannot use 'in' operator to
search for 'tool_calls' in undefined

What is the expected behavior?

Expecting it to not throw

What do you see instead?

TypeError: Cannot use 'in' operator to search for 'tool_calls' in undefined
    at $ze (file:///Users/leonli/workspace/codex/codex-cli/dist/cli.js:425:7661)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Iy.run (file:///Users/leonli/workspace/codex/codex-cli/dist/cli.js:599:2785)

Additional information

~/.codex/config.json

{
  "model": "o3",
  "providers": {
    "azure": {
      "name": "AzureOpenAI",
      "baseURL": "https://myhost.openai.azure.com/openai",
      "envKey": "AZURE_OPENAI_API_KEY"
    }
  }
}

View original on GitHub ↗

3 Comments

gadjio · 1 year ago

Thanks a lot @lazorfuzz for the fix — it completely resolves the initial error on my end! 🎉

However, I'm encountering a potential follow-up issue that might or might not be related: some shell actions (like adding a file to the Git repo) appear to return the correct command (git add AGENTS.md) but don’t seem to actually execute it.

{"role":"user","content":[{"type":"input_text","text":"Ajoute le fichier 'AGENTS.md' au git"}],"type":"message"}
{"type":"function_call","id":"msg_jjor9culu","status":"completed","call_id":"call_w7z5dzJGINrzLuWIWXrm2OOU","name":"shell","arguments":"{\"command\":[\"git add AGENTS.md\"],\"workdir\":\"/pgms/dev/w1\"}"}

{"role":"user","content":[{"type":"input_text","text":"Peux tu me donner le git status"}],"type":"message"}
{"type":"function_call","id":"msg_6sspcacnf","status":"completed","call_id":"call_sPWohczv9wJSG4l3ZUTmtn1u","name":"shell","arguments":"{\"command\":[\"git\",\"status\"],\"workdir\":\"/pgms/dev/w1\"}"}
{"type":"function_call_output","call_id":"call_sPWohczv9wJSG4l3ZUTmtn1u","output":"{\"output\":\"On branch dev\\nYour branch is up to date with 'origin/dev'.\\n\\nUntracked files:\\n  (use \\\"git add <file>...\\\" to include in what will be committed)\\n\\tAGENTS.md\\n\\nnothing added to commit but untracked files present (use \\\"git add\\\" to track)\\n\",\"metadata\":{\"exit_code\":0,\"duration_seconds\":0}}"}
{"type":"message","id":"msg_vi6up49d0","status":"completed","role":"assistant","content":[{"type":"output_text","text":"Voici le statut de votre dépôt Git :\n\n- Vous êtes sur la branche **dev**.\n- Votre branche est à jour avec **origin/dev**.\n\n**Fichiers non suivis :**\n- `AGENTS.md` (utilisez `git add <file>...` pour inclure dans ce qui sera commis)\n\nIl n'y a rien à commettre, mais des fichiers non suivis sont présents. Si vous avez besoin d'aide pour gérer ces fichiers, faites-le moi savoir !","annotations":[]}]}

Oddly enough, other shell commands like git status seem to execute just fine.

Have you encountered anything like this in your own tests?

lazorfuzz · 1 year ago
Oddly enough, other shell commands like git status seem to execute just fine. Have you encountered anything like this in your own tests?

Hey, I haven't seen this. It's odd that we don't see the function_call_output response, but the function call below is virtually the same. Doesn't seem related. I tested and got an output:

{"type":"function_call","id":"msg_5nmopxt2d","status":"completed","call_id":"call_H6y5JOtMtdureHKxcSBGRWJX","name":"shell","arguments":"{\"command\":[\"bash\",\"-lc\",\"git add AGENTS.md\"]}"}
{"type":"function_call_output","call_id":"call_H6y5JOtMtdureHKxcSBGRWJX","output":"{\"output\":\"git: warning: confstr() failed with code 5: couldn't get path of DARWIN_USER_TEMP_DIR; using /tmp instead\\ngit: error: couldn't create cache file '/tmp/xcrun_db-BhXG4FJG' (errno=Operation not permitted)\\n2025-05-30 11:23:41.656 xcodebuild[1409:5564783]  DVTFilePathFSEvents: Failed to start fs event stream.\\n2025-05-30 11:23:41.893 xcodebuild[1409:5564782] [MT] DVTDeveloperPaths: Failed to get length of DARWIN_USER_CACHE_DIR from confstr(3), error = Error Domain=NSPOSIXErrorDomain Code=5 \\\"Input/output error\\\". Using NSCachesDirectory instead.\\n\",\"metadata\":{\"exit_code\":143,\"duration_seconds\":10}}"}
codex-maintainers · 1 year ago

Thank you for the feedback! Please try running your setup with the latest version of Codex CLI. If the issue persists, we'd appreciate if you could verify it on the native/Rust implementation of Codex CLI.