Skip to content

fix(workflow): preserve Annotated text and content schemas - #7567

Open
BlueRaddish wants to merge 1 commit into
google:mainfrom
BlueRaddish:fix/oct15-adk
Open

BlueRaddish wants to merge 1 commit into
google:mainfrom
BlueRaddish:fix/oct15-adk

Conversation

@BlueRaddish

Copy link
Copy Markdown
Contributor

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, ...] or Annotated[Content, ...]. A node with a string output schema can parse JSON-looking text such as 123, true, or "quoted" before validation, either rejecting valid text or removing its quotes. Annotated Content schemas similarly parse the message text instead of preserving the message.

Solution: Unwrap Annotated in 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:

  • Added three regressions through a real two-node Workflow and Runner: the producer returns Event(output=Content(...)) with an annotated string output schema, and the consumer receives the exact original JSON-looking text.
  • Added two annotated-content/optional-content regressions and a constraint-rejection control.
  • The same five regressions pass with the patch and fail on the unchanged production baseline. Import paths and baseline source hashes are checked; constructor, collection and import errors are rejected as regression evidence.
  • The three owning schema/function-node/parallel-worker test files pass in every supported interpreter.
  • The unchanged full tox matrix passes on standard public Ubuntu runners against exact normally-hooked native commit 446f4cacda4785a95d47584de1dfd60176e08d66. Source/import origins, configuration, patch identity and the generated untracked lock are checked before/after. Standalone uv 0.12.23 uses supported TOX_UV_PATH; no project dependencies or test exclusions change.
Python Full-suite job Passed Skipped Xfailed Xpassed
3.11 job 19516 91 17 2
3.12 job 19507 92 17 2
3.13 job 19507 92 17 2
3.14 job 19507 92 17 2

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

  • I have read CONTRIBUTING.md.
  • I have performed a self-review of my own code (AI-assisted; not a claim of human/maintainer review).
  • Tests prove the fix through its real consuming path and preserve metadata validation.
  • New and existing tests pass in all four full tox environments on hosted Ubuntu.
  • I have manually tested a live model or browser.

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.

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants