---
type: email
from: Muhammad_Sami <notifications@github.com>
subject: [openai/openai-agents-python] fix(agent): stricter validation for

 Agent.prompt type checking (PR #1571)
received: 2026-03-06 07:12:35
date_header: Sat, 23 Aug 2025 09:10:46 -0700
priority: normal
status: awaiting_approval
uid: 28485
---

## Email Content

**From:** Muhammad_Sami <notifications@github.com>
**Subject:** [openai/openai-agents-python] fix(agent): stricter validation for

 Agent.prompt type checking (PR #1571)
**Date:** Sat, 23 Aug 2025 09:10:46 -0700

### Body (preview)

This PR improves the validation logic for the Agent.prompt field in agent.py.



🔧 Changes



⚫ Replaced hasattr(self.prompt, &quot;get&quot;) check with a strict isinstance(self.prompt, Prompt) check.



⚫ Ensures only valid Prompt objects or DynamicPromptFunction (callable) are accepted.



⚫ Prevents invalid objects (e.g., dict with .get() method) from being mistakenly allowed.



✅ Why this matters



⚫ Increases type safety and prevents runtime errors when an invalid prompt object is passed.



⚫ Makes the behavior more predictable and aligned with the intended usage (Prompt | DynamicPromptFunction | None).

You can view, comment on, or merge this pull request online at:



  https://github.com/openai/openai-agents-python/pull/1571



-- Commit Summary --



  * fix(agent): validate Agent.prompt against Prompt class instead of hasattr(get)



-- File Changes --



    M src/agents/agent.py (13)



-- Patch Links --



https://github.com/openai/openai-agents-python/pull/1571.patch

https://github.com/openai/openai-agents-python/pull/1571.diff



-- 

Reply to this email directly or view it on GitHub:

https://github.com/openai/openai-agents-python/pull/1571

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



Message ID: &lt;openai/openai-agents-python/pull/1571@github.com&gt;

---

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