Skip to content

Conversation

@strands-agent
Copy link
Contributor

@strands-agent strands-agent commented Jan 13, 2026

Superseded

This PR has been superseded by PR #1472 which implements Option 1 (modifying __str__ directly) as requested by @afarntrog.

Closing this PR in favor of the cleaner approach.

Fixes strands-agents#1461

Problem:
When graph nodes return both text and structured_output, only the text
was being propagated to the next node. This was because graph.py called
str() on AgentResult, and AgentResult.__str__() only returns
structured_output when there is NO text content.

Solution:
1. Added AgentResult.to_graph_input_text() method that returns both
   text AND structured_output (when present), clearly labeled
2. Updated graph.py to call to_graph_input_text() instead of str()
3. Preserved __str__() behavior for backward compatibility

This ensures that downstream nodes receive complete information from
upstream nodes, enabling proper data flow in graph-based workflows.

Changes:
- src/strands/agent/agent_result.py: Added to_graph_input_text() method
- src/strands/multiagent/graph.py: Use to_graph_input_text() in _build_node_input()
- tests/strands/agent/test_agent_result_graph_input.py: Comprehensive test coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant