fix(workflow): Preserve explicit single-turn contents#6047
fix(workflow): Preserve explicit single-turn contents#6047spectaclehong wants to merge 4 commits into
Conversation
single_turn workflow nodes previously forced include_contents to none even when users explicitly set include_contents='default'. Use Pydantic field tracking to keep explicit values while preserving the implicit default. Fixes google#6046
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Response from ADK Triaging Agent Hello @spectaclehong, thank you for your contribution! We noticed that a couple of things are missing according to our contribution guidelines:
This information will help reviewers to review your PR more efficiently. Thanks! |
|
Hi @spectaclehong , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share. |
|
Hi @GWeale , can you please review this. |
Merge #6047 **Please ensure you have read the [contribution guide](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) before creating a pull request.** ### Link to Issue or Description of Change **1. Link to an existing issue (if applicable):** - Closes: #6046 **Problem:** `single_turn` `LlmAgent` workflow nodes currently force `include_contents` to `none` at runtime, even when the user explicitly configures `include_contents="default"`. That silently changes the agent configuration and prevents one-shot workflow nodes from intentionally receiving relevant session or workflow history. **Solution:** Only apply the workflow `single_turn` default of `include_contents="none"` when `include_contents` was not explicitly set by the user. This preserves the existing implicit default behavior while respecting explicit `include_contents="default"` and `include_contents="none"` values. Regression coverage was added for implicit and explicit `include_contents` cases. ### Testing Plan **Unit Tests:** - [x] I have added or updated unit tests for my change. - [x] All unit tests pass locally. Targeted workflow tests pass locally: ```shell uv run pytest tests/unittests/workflow/test_llm_agent_as_node.py -q ``` Result: ```text 28 passed, 8 skipped, 4 xfailed ``` Python 3.10 tox unit suite passes locally: ```shell uv tool run --from tox --with tox-uv tox -e py310 ``` Result: ```text 7044 passed, 21 skipped, 31 xfailed, 9 xpassed ``` Pre-commit hooks pass for changed files: ```shell uv run pre-commit run --files src/google/adk/workflow/_llm_agent_wrapper.py tests/unittests/workflow/test_llm_agent_as_node.py ``` **Manual End-to-End (E2E) Tests:** Validated manually with a local workflow application that uses a `single_turn` workflow `LlmAgent` configured with `include_contents="default"`. The run confirmed that the explicit contents mode is preserved instead of being overwritten to `none`. No ADK Web or UI behavior is changed. ### Checklist - [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document. - [x] I have performed a self-review of my own code. - [x] I have commented my code, particularly in hard-to-understand areas. - [x] I have added tests that prove my fix is effective or that my feature works. - [x] New and existing unit tests pass locally with my changes. - [x] I have manually tested my changes end-to-end. - [x] Any dependent changes have been merged and published in downstream modules. ### Additional context No documentation update was made because this change does not add a new user-facing API or guide behavior; it preserves explicit configuration that was already supported by `LlmAgent.include_contents`. No dependent changes are required. Co-authored-by: Bo Yang <ybo@google.com> COPYBARA_INTEGRATE_REVIEW=#6047 from spectaclehong:fix/single-turn-include-contents a98ad26 PiperOrigin-RevId: 931343211
|
Thank you @spectaclehong for your contribution! 🎉 Your changes have been successfully imported and merged via Copybara in commit 59f7bdf. Closing this PR as the changes are now in the main branch. |
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
single_turnworkflow nodes overwrite explicitinclude_contents#6046Problem:
single_turnLlmAgentworkflow nodes currently forceinclude_contentstononeat runtime, even when the user explicitly configuresinclude_contents="default". That silently changes the agent configuration and prevents one-shot workflow nodes from intentionally receiving relevant session or workflow history.Solution:
Only apply the workflow
single_turndefault ofinclude_contents="none"wheninclude_contentswas not explicitly set by the user. This preserves the existing implicit default behavior while respecting explicitinclude_contents="default"andinclude_contents="none"values.Regression coverage was added for implicit and explicit
include_contentscases.Testing Plan
Unit Tests:
Targeted workflow tests pass locally:
Result:
Python 3.10 tox unit suite passes locally:
Result:
Pre-commit hooks pass for changed files:
Manual End-to-End (E2E) Tests:
Validated manually with a local workflow application that uses a
single_turnworkflowLlmAgentconfigured withinclude_contents="default". The run confirmed that the explicit contents mode is preserved instead of being overwritten tonone.No ADK Web or UI behavior is changed.
Checklist
Additional context
No documentation update was made because this change does not add a new user-facing API or guide behavior; it preserves explicit configuration that was already supported by
LlmAgent.include_contents.No dependent changes are required.