Commit 54344ed
fix(agents): skip output_key processing on intermediate conversational text in task-mode LlmAgent
Task-mode LlmAgents produce intermediate conversational text responses (such as clarification questions or greetings) before completing their task via finish_task.
When output_key and output_schema were configured on a task-mode agent, ADK attempted to validate intermediate conversational text against output_schema during state_delta processing, causing a ValidationError crash on non-JSON text.
- Skip output_key state_delta processing on intermediate text responses for task-mode agents (mode="task") in __maybe_save_output_to_state and _save_output_to_state.
- Preserve output_schema validation for non-task agents.
- Ensure task-mode finish_task validated output is written to output_key state_delta on task completion.
- Add unit tests for task-mode output_key handling.
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 9493574581 parent d4804e2 commit 54344ed
3 files changed
Lines changed: 40 additions & 0 deletions
File tree
- src/google/adk
- agents
- workflow
- tests/unittests/agents
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
967 | 967 | | |
968 | 968 | | |
969 | 969 | | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
970 | 975 | | |
971 | 976 | | |
972 | 977 | | |
| |||
1016 | 1021 | | |
1017 | 1022 | | |
1018 | 1023 | | |
| 1024 | + | |
1019 | 1025 | | |
1020 | 1026 | | |
1021 | 1027 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
| 432 | + | |
| 433 | + | |
432 | 434 | | |
433 | 435 | | |
434 | 436 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
153 | 185 | | |
154 | 186 | | |
155 | 187 | | |
| |||
0 commit comments