Skip to content

Conversation

muhammadsami987123
Copy link

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

🔧 Changes

⚫ Replaced hasattr(self.prompt, "get") 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).

…attr(get)

fix(agent): validate Agent.prompt against Prompt class instead of hasattr(get)
@seratch
Copy link
Member

seratch commented Aug 24, 2025

Your code's Python indentation looks broken. But more importantly, Prompt class is TypedDict, so I don't think simply checking this way can work out well. Thanks for your interest and sending this!

@seratch seratch closed this Aug 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants