---
type: email
from: "chatgpt-codex-connector[bot]" <notifications@github.com>
subject: Re: [openai/openai-agents-python] Fix: call

 `_fix_tool_message_ordering` for all Anthropic models (PR #1936)
received: 2026-03-06 08:08:49
date_header: Sun, 19 Oct 2025 07:45:39 -0700
priority: normal
status: awaiting_approval
uid: 32996
---

## Email Content

**From:** "chatgpt-codex-connector[bot]" <notifications@github.com>
**Subject:** Re: [openai/openai-agents-python] Fix: call

 `_fix_tool_message_ordering` for all Anthropic models (PR #1936)
**Date:** Sun, 19 Oct 2025 07:45:39 -0700

### Body (preview)

@chatgpt-codex-connector[bot] commented on this pull request.





### 💡 Codex Review



Here are some automated review suggestions for this pull request.

    



<details> <summary>ℹ️ About Codex in GitHub</summary>

<br/>



Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

- Open a pull request for review

- Mark a draft as ready

- Comment "@codex review".



If Codex has suggestions, it will comment; otherwise it will react with 👍.









When you [sign up for Codex through ChatGPT](https://openai.com/codex), Codex can also answer questions or update the PR, like "@codex address that feedback".

            

</details>



>          # Fix for interleaved thinking bug: reorder messages to ensure tool_use comes before tool_result  # noqa: E501

-        if preserve_thinking_blocks:

+        if 'anthropic' in self.model.lower():

             converted_messages = self._fix_tool_message_ordering(converted_messages)



**<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub>  Detect anthropic models without relying on substring**



The new guard `if 'anthropic' in self.model.lower()` will only reorder tool messages when the model string literally contains "anthropic". Litellm accepts canonical Anthropic model IDs such as `"claude-3-sonnet-20240229"` or user‑defined aliases that omit that substring; those values no longer trigger `_fix_tool_message_ordering`, even when reasoning is enabled. The previous condition ran the fix whenever interleaved thinking was preserved, so this change regresses those configurations and the Anthropic API will still reject histories where tool results precede tool calls. Consider deriving the provider from the model settings or checking for `"claude"`/known Anthropic prefixes instead of a literal substring match.



Useful? React with 👍 / 👎.



-- 

Reply to this email directly or view it on GitHub:

https://github.com/openai/openai-agents-pytho

---

## Suggested Actions
- [ ] Reply
- [ ] Archive
- [ ] Escalate
