Skip to content

bug: tool_calls must be followed by tool messages error when creating prefix approval rules #25097

@hmx7

Description

@hmx7

Bug: ool_calls must be followed by ool messages error when approving prefix rules

Environment

  • Application: Codex Desktop (Windows)
  • Version: v0.135.0

Steps to Reproduce

  1. Trigger a command requiring escalated permissions (write file, install package)
  2. Click Yes, and don't ask again for commands that start with...
  3. Error appears:
{"error":{"message":"An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'."}}

Expected

Prefix rule saved, command executes normally.

Actual

API call fails. The approval flow breaks the required assistant(tool_calls) -> tool message pairing.

Root Cause

When the approval UI modifies internal message history, it violates the OpenAI API invariant that every assistant message with tool_calls must be immediately followed by corresponding tool messages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtool-callsIssues related to tool calling

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions