---
type: email
from: "chatgpt-codex-connector[bot]" <notifications@github.com>
subject: Re: [openai/openai-agents-python] fix: raise UserError instead of

 TypeError for Agent validation (fixes #1443) (PR #1927)
received: 2026-03-06 08:08:10
date_header: Sat, 18 Oct 2025 10:49:52 -0700
priority: normal
status: awaiting_approval
uid: 32921
---

## Email Content

**From:** "chatgpt-codex-connector[bot]" <notifications@github.com>
**Subject:** Re: [openai/openai-agents-python] fix: raise UserError instead of

 TypeError for Agent validation (fixes #1443) (PR #1927)
**Date:** Sat, 18 Oct 2025 10:49:52 -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/>



[Your team has set up Codex to review pull requests in this repo](http://chatgpt.com/codex/settings/general). 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 👍.









Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

            

</details>



>              and not isinstance(self.instructions, str)

             and not callable(self.instructions)

         ):

-            raise TypeError(

+            raise UserError(

                 f"Agent instructions must be a string, callable, or None, "

                 f"got {type(self.instructions).__name__}"



**<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub>  Switching instructions type validation to UserError breaks existing expectations**



Changing the `instructions` validation to raise `UserError` means `Agent(...)` now raises `UserError` when `instructions` is not a string or callable. Other tests still expect a `TypeError` in that scenario (`tests/test_agent_instructions_signature.py::test_non_callable_instructions_raises_error`), so the suite fails. If the intent is to migrate all validation errors to `UserError`, those tests and any callers relying on `TypeError` need to be updated or `UserError` must remain compatible (e.g. subclass or alias).



Useful? React with 👍 / 👎.



-- 

Reply to this email directly or view it on GitHub:

https://github.com/openai/openai-agents-python/pull/1927#pullrequestreview-3353694781

You are receiving this because you are subscribed to this thread.



Message ID: <openai/openai-agents-python/pull/1927/review/3353694781

---

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