Skip to content

invalid_request_error: Invalid 'messages[XX].tool_calls[0].function.name': empty string. Expected a string with minimum length 1, but got an empty string instead. #7628

Closed

Description

@timvw

What version of Codex is running?

codex-cli 0.65.0

What subscription do you have?

Azure OpenAI deployment

Which model were you using?

gpt-5.1-codex

What platform is your computer?

Darwin 25.1.0 arm64 arm

What issue are you seeing?

A simple session, simply saying "hi" is responded with:

{
  "error": {
    "message": "Invalid 'messages[5].tool_calls[0].function.name': empty string. Expected a string with minimum length 1, but got an empty string instead.",
    "type": "invalid_request_error",
    "param": "messages[5].tool_calls[0].function.name",
    "code": "empty_string"
  }
}

What steps can reproduce the bug?

Uploaded thread: 019aed70-d44c-7202-b4e1-3a2a1e3d1f9a

What is the expected behavior?

The assistant should respond normally to the greeting without errors. Tool call function names should be preserved from the initial SSE delta and not overwritten by empty strings in subsequent deltas.

Additional information

Related Issues:
This appears to be related to:

Root Cause:
The SSE streaming parser (since v0.64.0 / PR #6996) unconditionally overwrites tool call function names with values from subsequent deltas. Azure OpenAI and other providers send the tool name in the first delta, then send empty strings in subsequent deltas containing only arguments. The current parser overwrites the valid name with these empty strings.

Environment Notes:

  • Issue does NOT occur with ChatGPT Pro subscription (non-Azure)
  • Issue started in version 0.64.0 (worked correctly in 0.63.0)
  • Affects Azure OpenAI and other OpenAI-compatible providers (LM Studio, etc.)

Fix Status:
A fix has been developed that prevents empty strings from overwriting valid tool names during SSE delta parsing. See: https://github.com/timvw/codex/tree/fix/empty-tool-call-names

Activity

  1. added
    bug
    on Dec 5, 2025
  2. added
    CLI
    azure
    tool-calls
    on Dec 5, 2025
  3. github-actions commented on Dec 5, 2025

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  4. timvw commented on Dec 5, 2025

    @timvw
    Author

    When using chatgpt pro subscription I do not experience the issue.. So indeed, related to Azure deployment...

  5. etraut-openai commented on Dec 5, 2025

    @etraut-openai
    Contributor

    In your Azure model provider config, are you specifying wire_api = "responses", or are you using the default wire_api = "chat"? We recommend uses the "responses" API, and that should also work around this problem.

  6. timvw commented on Dec 5, 2025

    @timvw
    Author

    Indeed, using the responses API also works around the issue...

    For people coming after me, I need to update my codex config (base_url and query_params are different when using responses api:

    [model_providers.azure]
    name = "Azure (XXX)"
    base_url = "https://XXX.azure.com/openai/deployments/gpt-5.1-codex"
    env_key = "AZURE_OPENAI_API_KEY"
    query_params = { api-version = "2024-08-01-preview" }
    wire_api = "chat"
    
    [model_providers.azure_responses]
    name = "Azure Responses API (XXX)"
    base_url = "https://XXX.openai.azure.com/openai/v1"
    env_key = "AZURE_OPENAI_API_KEY"
    query_params = { api-version = "preview" }
    wire_api = "responses"
  7. etraut-openai commented on Dec 5, 2025

    @etraut-openai
    Contributor

    We've implemented a fix for this issue and published a new prerelease build 0.66.0-alpha.7 if you'd like to validate that it addresses the problem you are seeing.

  8. timvw commented on Dec 6, 2025

    @timvw
    Author

    I tested v0.66.0-alpha.8 and can confirm that the issue does not exist in that version.

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