Repository navigation
fix(workflow): preserve Annotated text and content schemas - #7567
Open
BlueRaddish wants to merge 1 commit into
Open
BlueRaddish wants to merge 1 commit into
BlueRaddish wants to merge 1 commit into
Conversation
Unwrap Annotated when choosing whether node content is text or a message. Keep JSON-looking string output intact and retain Pydantic metadata validation. AI-assisted with OpenAI Codex.
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds support for handling typing.Annotated types in schema utility functions. Specifically, annotation_expects_str and annotation_accepts_content in _schema_utils.py are updated to extract the underlying type when wrapped in Annotated. Corresponding unit tests have been added to verify that Annotated content schemas preserve content, string schemas enforce constraints, and annotated string outputs preserve JSON-looking text. I have no feedback to provide as there are no review comments.
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
Problem: Node content conversion does not recognize
Annotated[str, ...]orAnnotated[Content, ...]. A node with a string output schema can parse JSON-looking text such as123,true, or"quoted"before validation, either rejecting valid text or removing its quotes. AnnotatedContentschemas similarly parse the message text instead of preserving the message.Solution: Unwrap
Annotatedin the two existing annotation predicates, including when they recurse into a union. Pydantic still receives the original annotation and enforces its metadata. The shared correction applies to node input/output validation and the function-node/parallel-worker content converters without changing their interfaces.Testing Plan
Unit Tests:
WorkflowandRunner: the producer returnsEvent(output=Content(...))with an annotated string output schema, and the consumer receives the exact original JSON-looking text.toxmatrix passes on standard public Ubuntu runners against exact normally-hooked native commit446f4cacda4785a95d47584de1dfd60176e08d66. Source/import origins, configuration, patch identity and the generated untracked lock are checked before/after. Standalone uv 0.12.23 uses supportedTOX_UV_PATH; no project dependencies or test exclusions change.Normal scoped pre-commit checks and the actual Git pre-commit hook pass in each job. The linked raw logs retain warnings and test-defined skips/xfails/xpasses.
Manual End-to-End (E2E) Tests: The new workflow regression executes the real offline Runner path rather than calling a duplicate converter. Reproduce it with
pytest tests/unittests/workflow/test_function_node.py -k annotated_string_output_preserves_json_looking_text. It requires no model, credentials, network endpoint, or ADK Web server. No live-model or manual browser validation is claimed.Checklist
Additional context
Four production lines in the shared internal predicates; no dependency, public API, serialized-state, prompt, or unrelated formatting change. AI-assisted with OpenAI Codex.