Repository navigation
fix(schema): keep structured output JSON serializable - #7591
Open
BlueRaddish wants to merge 1 commit into
Open
BlueRaddish wants to merge 1 commit into
BlueRaddish wants to merge 1 commit into
Conversation
Serialize validated model output in JSON mode so date-valued AgentTool results survive the real Runner and tool-result serialization. Keep the existing exclusion of None fields for model and list output schemas. Related to google#7480. AI-assisted with OpenAI Codex.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Related to the structured-output serialization problem in #7480. This addresses its date-valued AgentTool output case.
Problem: Validating JSON against a Pydantic output schema currently dumps the resulting model in Python mode. A JSON string such as
{"day":"2026-10-17"}becomes a dictionary containing adatetime.date. The real Runner can carry that value into an AgentTool function response, where the Anthropic converter raisesTypeError: Object of type date is not JSON serializable.Solution: Dump validated model and list-of-model output in JSON mode, retaining the existing exclusion of
Nonefields. The shared helper also serves LlmAgent output state and workflow output processing. No API or dependency changes are introduced.Testing Plan
The identical three new tests produce three genuine baseline failures: model and list output retain Python dates, and an actual offline Runner / AgentTool function response fails in the real public Anthropic converter. All three pass after the fix. The complete schema, AgentTool, LlmAgent workflow-node and Anthropic owning files pass 401 tests.
Exact normally-hooked native commit
a01591c78332256ca14579184f4e9091779d3851passes the unchanged full supported tox matrix on four isolated public Ubuntu runners:The supported tox configuration, source hashes, actual import origins and generated dependency lock are verified before and after execution. Normal scoped hooks and the actual Git pre-commit hook pass without changing the frozen patch. Raw logs retain warnings and normal test-defined skips, xfails and xpasses.
Unit Tests:
Manual End-to-End (E2E) Tests:
The consuming test runs the repository's scripted model through its real InMemoryRunner and AgentTool, then converts the resulting function-response part with
part_to_message_block. It uses no live model or provider endpoint. Live provider acceptance and browser behavior were not tested.Checklist
Additional context
OpenAI Codex assisted with diagnosis, implementation, deterministic verification and this description. A complete current open-PR path inventory and the matching diffs were reviewed for supersession. The other
validate_schemaproposal, #7285, validates non-model schemas and leaves the model dumps unchanged.