Skip to content

Commit 0014a2b

Browse files
foxxqinFox Qin
andauthored
fix(workflow): Allow workflow tasks access results from previous dependent tasks (#202)
Co-authored-by: Fox Qin <[email protected]>
1 parent da7f0c0 commit 0014a2b

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/strands_tools/workflow.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,11 @@ def execute_task(self, task: Dict, workflow: Dict) -> Dict:
445445

446446
# Extract response content - handle both dict and custom object return types
447447
try:
448-
content = result.get("content", []) if hasattr(result, "get") else getattr(result, "content", [])
448+
content = (
449+
result.message.get("content", [])
450+
if hasattr(result.message, "get")
451+
else getattr(result.message, "content", [])
452+
)
449453
except AttributeError:
450454
content = [{"text": str(result)}]
451455

tests/test_workflow.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import pytest
1111
from strands import Agent
12+
from strands.agent import AgentResult
1213
from strands_tools import workflow as workflow_module
1314

1415

@@ -426,14 +427,11 @@ def test_execute_task_success(self, mock_parent_agent, mock_agent_result):
426427
):
427428
# Create a proper mock agent result that returns structured data
428429
mock_task_agent = MagicMock()
429-
mock_result = MagicMock()
430-
mock_result.__str__ = MagicMock(return_value="Task completed successfully")
431-
mock_result.get = MagicMock(
432-
side_effect=lambda k, default=None: {
433-
"content": [{"text": "Task completed successfully"}],
434-
"stop_reason": "completed",
435-
"metrics": None,
436-
}.get(k, default)
430+
mock_result = AgentResult(
431+
message={"content": [{"text": "Task completed successfully"}]},
432+
stop_reason="completed",
433+
metrics=None,
434+
state=MagicMock(),
437435
)
438436

439437
mock_task_agent.return_value = mock_result

0 commit comments

Comments
 (0)