Skip to content

fix(workflow): keep schema defaults for missing resume fields - #8370

Open
feiiiiii5 wants to merge 2 commits into
google:mainfrom
feiiiiii5:feiiiiii5/1126-D269
Open

feiiiiii5 wants to merge 2 commits into
google:mainfrom
feiiiiii5:feiiiiii5/1126-D269

Conversation

@feiiiiii5

Copy link
Copy Markdown
Contributor

Please ensure you have read the contribution guide before creating this pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:

Problem: _validate_resume_response() built non-required object fields as (prop_type | None, None), ignoring the default declared in the JSON schema. A partial resume answer such as {"approved": true} for Decision(approved: bool, priority: int = 3, tags: list = [], reviewer: str = "manager") produced None for the other fields, so the next node failed Pydantic validation.

Solution: use prop_schema.get("default") for non-required fields. Required fields keep (prop_type, ...), and fields without a JSON-schema default behave exactly as before. Field(default_factory=...) emits no default and remains out of scope per the issue.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Two new tests: declared defaults retained for missing fields, and explicit values overriding defaults. Base-red: 1 failed / 81 passed ({'priority': None} != {'priority': 3}); with fix 82/82 passed. Broader workflow utils: 283 passed. ruff check on the source file clean (one pre-existing unused import in the test file is outside the repo's ruff scope).

Manual End-to-End (E2E) Tests:

Not run offline: no real model, credentials, or network available. This is pure schema handling verified at unit level.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end (offline environment; see above).
  • Any dependent changes have been merged and published in downstream modules.

Additional context

The repo uses pyink (unavailable offline), so ruff format was not used; new code matches surrounding 2-space/single-quote style. Full suite could not be collected offline due to a pre-existing missing a2a module.

@chaitanya0305

Copy link
Copy Markdown

Hi @feiiiiii5, thanks for picking this up. On #8359, @surajksharma07 suggested also covering the default_factory case: leave a field out of the answer when the schema has no default and it wasn't given, so the next node's model fills it in.

With this PR as it stands, tags: list[str] = Field(default_factory=list) still comes back as None for the answer {"approved": true}, so a node typed with the model fails with Input should be a valid list.

A minimal change on top of yours that fixes it:

      fields: dict[str, Any] = {}
      no_default: set[str] = set()
      for prop_name, prop_schema in properties.items():
        ...
        else:
          if 'default' not in prop_schema:
            no_default.add(prop_name)
          fields[prop_name] = (
              prop_type | None,
              prop_schema.get('default'),
          )
      ...
        return model_instance.model_dump(
            exclude=no_default - model_instance.model_fields_set
        )

A given value, None included, is still kept. I tested it end to end with a node typed with the model and with a dict-typed node, in resumable and non-resumable mode. The tests are on this branch if you want to pull them in: chaitanya0305/adk-python@main...chaitanya0305:adk-python:fix/resume-schema-defaults-v2 (see test_object_schema_leaves_out_omitted_fields_without_default, test_object_schema_keeps_given_fields_without_default and test_resume_answer_omitting_optional_fields_keeps_defaults).

Happy to help if useful.

@feiiiiii5

Copy link
Copy Markdown
Contributor Author

Thanks @chaitanya0305 — this is a real gap. I folded the no_default approach into #8370: omitted properties with no JSON-schema default are excluded from the dump unless the answer actually carried them (so an explicit None is still kept), while declared defaults are unchanged.

Verification on the pushed head f2ffab3a8594f98f3c6e6c9311df71f72c7c4553: the three new regressions are 2 failed / 1 passed against the previous source and 3 passed with the fix; the focused test file is 85 passed and the wider workflow/utils directory 304 passed. ruff check is clean on the source file (the test file has one pre-existing F401 unrelated to this change). No real model or network was used — this is pure schema handling.

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