Skip to content

How would you handle Pydantic output_type validation and retries? #530

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

Closed
jackien1 opened this issue Apr 16, 2025 · 3 comments
Closed

How would you handle Pydantic output_type validation and retries? #530

jackien1 opened this issue Apr 16, 2025 · 3 comments
Labels
question Question about using the SDK stale

Comments

@jackien1
Copy link

If you want to double check that a property like "pdf_id" that the AI spits out in structured output exists in the database would you just run a while loop checker with max iterations, dynamic model creation of enums or literals, or use AfterValidator? Not sure what is the best practice for this agentic SDK.

@jackien1 jackien1 added the question Question about using the SDK label Apr 16, 2025
@rm-openai
Copy link
Collaborator

I think the most straightforward thing would be to take the final output, so the validation, and it the validation failed - re-run the agent with the previous input list plus a new message saying that the output was invalid. Something like "pdf didn't exist, please fix"

Copy link

This issue is stale because it has been open for 7 days with no activity.

@github-actions github-actions bot added the stale label Apr 24, 2025
Copy link

This issue was closed because it has been inactive for 3 days since being marked as stale.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about using the SDK stale
Projects
None yet
Development

No branches or pull requests

2 participants