Skip to content

Correct error message for invalid output types with strict JSON schema #1101

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

DanielHashmi
Copy link
Contributor

Problem

  1. Incorrect parameter reference: Suggests passing output_schema_strict=False to Agent(), but this parameter doesn't exist
  2. Vague guidance: The phrase "make the output type strict" doesn't explain HOW to make types strict

Solution

Updated the error message to provide accurate, actionable guidance:

Before:

"Either make the output type strict, or pass output_schema_strict=False to your Agent()"

After:

"Either use a dataclass, Pydantic model, or TypedDict, or wrap your type with AgentOutputSchema(your_type, strict_json_schema=False)"

@seratch seratch added documentation Improvements or additions to documentation feature:core labels Jul 14, 2025
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.

LGTM. @rm-openai what do you think?

@seratch seratch requested a review from rm-openai July 15, 2025 02:33
Copy link
Collaborator

@rm-openai rm-openai left a comment

Choose a reason for hiding this comment

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

Agree with the AgentOutputSchema... stuff, but we shouldn't recommend using a dataclass/pydantic etc, because any type is generally valid

@DanielHashmi DanielHashmi requested a review from rm-openai July 15, 2025 16:06
@DanielHashmi
Copy link
Contributor Author

@rm-openai Updated to only include AgentOutputSchema stuff 👍

@rm-openai rm-openai merged commit 99ba260 into openai:main Jul 16, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature:core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants