Skip to content

Fix: enforce strict instructions function signature in get_system_prompt #1426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

abdullahimran49
Copy link
Contributor

Previously, the Agent class allowed dynamic instructions functions with any two parameters,
including meaningless dummy names (e.g., def f(wrapper, a)), which caused confusion and
allowed improper usage.

This commit adds strict signature checking in get_system_prompt to ensure the instructions
callable accepts exactly two parameters (context and agent), enforcing correct usage.

If the function signature does not have exactly two parameters, a clear TypeError is raised.

This prevents dummy or incorrect parameter usage, improving API correctness and developer
experience.

Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change itself looks good to me. Once all the CI jobs pass, we can merge this contribution.

@seratch
Copy link
Member

seratch commented Aug 12, 2025

It seems the tests are still failing

@seratch seratch merged commit 534e2d5 into openai:main Aug 13, 2025
5 checks passed
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