Commit 59f7bdf
fix(workflow): Preserve explicit single-turn contents
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: 9313432111 parent b99546b commit 59f7bdf
3 files changed
Lines changed: 68 additions & 1 deletion
File tree
- .agents/skills/adk-unit-guide
- src/google/adk/workflow
- tests/unittests/workflow
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
| 299 | + | |
| 300 | + | |
300 | 301 | | |
301 | 302 | | |
302 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
249 | 314 | | |
250 | 315 | | |
251 | 316 | | |
| |||
0 commit comments