Commit 102e0fc
fix(agent): Return structured output JSON when AgentResult has no text (#1290)
* fix(agent): Return structured output JSON when AgentResult has no text
When AgentResult has no text content but structured_output is present,
__str__() now returns the JSON serialization of the structured output
instead of an empty string. This fixes output propagation in multi-agent
graphs where structured output was being lost.
Changes:
- Modified AgentResult.__str__() to fall back to structured_output.model_dump_json()
- Added unit test test__str__empty_message_with_structured_output to verify fix
- All existing tests pass, maintaining backward compatibility
#11181 parent cfa06c7 commit 102e0fc
File tree
2 files changed
+30
-1
lines changed- src/strands/agent
- tests/strands/agent
2 files changed
+30
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
0 commit comments