Skip to content

Empty function name cause Azure to reject the request #7094

Closed

Description

@dandanwei

What version of Codex is running?

v0.61.0

What subscription do you have?

BYOM

Which model were you using?

gpt-5.1-codex-mini, gpt-5.1-codex

What platform is your computer?

MacOS

What issue are you seeing?

We have the setup: Codex CLI --> LiteLLM --> Azure OpenAI Models

The request towards Azure got rejected because the function name is an empty string "". Below is the example messages in the rejected request. It worked before but maybe since yetserday Azure may changed the content policy to reject such requests. So now all such requests fails.

 "messages": [
    {
      "role": "system",
      "content": "You are Codex, based on GPT-5. ...."
    },
    {
      "role": "user",
      "content": "# AGENTS.md instructions for /....."
    },
    {
      "role": "user",
      "content": "<environment_context>\...."
    },
    {
      "role": "user",
      "content": "# Context from my IDE setup:...."
    },
    {
      "role": "assistant",
      "content": "Hey there! Let me know what you’d like to dig into."
    },
    {
      "role": "user",
      "content": "# Context from my IDE setup....n"
    },
    {
      "role": "assistant",
      "content": null,
      "tool_calls": [
        {
          "id": "call_NTEBXqjyLLvYusbiGf1fXZv2",
          "type": "function",
          "function": {
            "name": "",  <---- !!!!THE EMPTY Function Name!!!!!
            "arguments": "{\"command\":[\"bash\",\"-lc\",\"echo\"],\".........}"
          }
        }
      ]
    },
    {
      "role": "tool",
      "content": "unsupported call: ",
      "tool_call_id": "call_NTEBXqjyLLvYusbiGf1fXZv2"
    }
  ]

The function name is actually included in the previous response

"output": [
    {
      "id": "rs_0b20df85b294bee50069203508bab481959ac8ba55246426eb",
      "type": "reasoning",
      "status": null,
      "content": null,
      "summary": [],
      "encrypted_content": null
    },
    {
      "id": "fc_0b20df85b294bee5006920350ac7e48195bb74bb3610bd4480",
      "name": "shell",
      "type": "function_call",
      "status": "completed",
      "call_id": "call_NTEBXqjyLLvYusbiGf1fXZv2",
      "arguments": "{\"command\":[\"bash\",\"-lc\",\"echo\"],\"..."}"
    }
  ],

I have tried to fix it and made it work by hacking codex-rs/core/src/chat_completions.rs:692 to make it to be "shell_command" instead of empty string.

name: fn_call_state.name.clone().unwrap_or_else(|| "".to_string()),

==>

name: fn_call_state.name.clone().unwrap_or_else(|| "shell_command".to_string()),

What should be the proper fix? Got some suggestion from codex itself. just print below for your reference.

This should make for a concise GitHub issue describing the source of the empty-name bug and how to resolve it.

  • The Chat Completions SSE parser only captures function.name from the incremental delta.tool_calls chunks (codex-rs/core/src/chat_completions.rs:657-694). Azure’s updated
    policy now omits that name from the deltas and only provides it in the final choices[0]["message"]["tool_calls"][0]["function"] payload.
  • Because the parser never sees the name while aggregating, FunctionCallState.name stays None, we emit a function call with an empty string, and Azure immediately rejects the
    request (policy forbids empty function names).
  • The fix is to inspect the completed choice["message"]["tool_calls"] block when finish_reason == "tool_calls" and populate fn_call_state.name before emitting the
    ResponseItem::FunctionCall, so the actual tool name is forwarded instead of an empty string.

What steps can reproduce the bug?

  • Setup Codex CLI --> LiteLLM --> Azure OpenAI Models
    config.toml
[model_providers.openai-chat-completions]
name = "name"
base_url = "<litellm-url>"
env_key = "CODING_AGENT_KEY"
wire_api = "chat"
query_params = {}
  • start codex and ask "hello, just echo"

What is the expected behavior?

it will call a function to echo the text

Additional information

No response

Activity

  1. added
    bug
    on Nov 21, 2025
  2. added
    CLI
    azure
    tool-calls
    on Nov 21, 2025
  3. jeromeroussin commented on Nov 21, 2025

    @jeromeroussin

    This looks like the litellm bug reported here: BerriAI/litellm#16509 and addressed here: BerriAI/litellm#16864

  4. dandanwei commented on Nov 21, 2025

    @dandanwei
    Author

    This looks like the litellm bug reported here: BerriAI/litellm#16509 and addressed here: BerriAI/litellm#16864

    Thanks for the info! I will test the latest litellm build.

  5. scotty2 commented on Dec 4, 2025

    @scotty2

    I see the same behavior in LMStudio.
    Last working version for me is 0.63.0 (0.64.0 - 0.65.0 are broken)
    Since this is a dump directly from Codex, I don't not think it can be any fault on the LMS side.

        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-1",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "{\n"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-2",
              "type": "function",
              "function": {
                "name": "",
                "arguments": " "
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-3",
              "type": "function",
              "function": {
                "name": "",
                "arguments": " \""
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-4",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "command"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-5",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "\":"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-6",
              "type": "function",
              "function": {
                "name": "",
                "arguments": " [\""
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-7",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "bash"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-8",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "\","
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-9",
              "type": "function",
              "function": {
                "name": "",
                "arguments": " \"-"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-10",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "lc"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-11",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "\","
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-12",
              "type": "function",
              "function": {
                "name": "",
                "arguments": " \""
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-13",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "ls"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-14",
              "type": "function",
              "function": {
                "name": "",
                "arguments": " -"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-15",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "R"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-16",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "\"]"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-17",
              "type": "function",
              "function": {
                "name": "",
                "arguments": " ,\n"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-18",
              "type": "function",
              "function": {
                "name": "",
                "arguments": " "
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-19",
              "type": "function",
              "function": {
                "name": "",
                "arguments": " \""
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-20",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "work"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-21",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "dir"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-22",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "\":"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-23",
              "type": "function",
              "function": {
                "name": "",
                "arguments": " \"/"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-24",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "Users"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-25",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "/s"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-26",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "walker"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-27",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "/"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-28",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "ll"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-29",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "m"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-30",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "/"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-31",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "agents"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-32",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "/s"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-33",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "mok"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-34",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "eping"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-35",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "\"\n"
              }
            }
          ]
        },
        {
          "role": "assistant",
          "content": null,
          "tool_calls": [
            {
              "id": "tool-call-36",
              "type": "function",
              "function": {
                "name": "",
                "arguments": "}"
              }
            }
          ]
        },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIazurebugtool-calls

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions