Skip to content

Commit 62119eb

Browse files
committed
[Bug] SequentialWorkflow.run accepts imgs and then drops it
run() takes an imgs parameter and documents it as "Optional list of images for the agents", but only task and img ever make it into the kwargs handed to AgentRearrange: run_kwargs = {"task": task} if img is not None: run_kwargs["img"] = img So a multi-image run silently degrades to a text-only run. No error, no warning -- the agents just answer a question about images they were never shown. AgentRearrange forwards **kwargs down to Agent.run, which does accept imgs, so passing it through is all that's needed.
1 parent fd9c2e0 commit 62119eb

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

swarms/structs/sequential_workflow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ def run(
329329
run_kwargs = {"task": task}
330330
if img is not None:
331331
run_kwargs["img"] = img
332+
if imgs is not None:
333+
run_kwargs["imgs"] = imgs
332334
result = self.agent_rearrange.run(**run_kwargs)
333335

334336
# Run drift detection if configured

tests/structs/test_sequential_workflow.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,30 @@ def test_workflow_drift_max_retries_zero_never_reruns():
612612
def test_negative_drift_max_retries_is_rejected():
613613
with pytest.raises(ValueError, match="drift_max_retries"):
614614
_make_workflow(drift_detection=True, drift_max_retries=-1)
615+
616+
617+
def test_run_forwards_imgs_to_the_pipeline():
618+
"""run(imgs=[...]) must reach the agents, not be dropped.
619+
620+
imgs is an accepted, documented parameter, but it was never put
621+
into the kwargs handed to AgentRearrange, so multi-image runs
622+
silently became text-only runs.
623+
"""
624+
wf = _make_workflow()
625+
with patch.object(
626+
wf.agent_rearrange, "run", return_value="out"
627+
) as pipeline:
628+
wf.run("describe these", imgs=["a.png", "b.png"])
629+
630+
assert pipeline.call_args.kwargs["imgs"] == ["a.png", "b.png"]
631+
632+
633+
def test_run_omits_imgs_when_not_supplied():
634+
"""No imgs key when the caller didn't pass one."""
635+
wf = _make_workflow()
636+
with patch.object(
637+
wf.agent_rearrange, "run", return_value="out"
638+
) as pipeline:
639+
wf.run("plain task")
640+
641+
assert "imgs" not in pipeline.call_args.kwargs

0 commit comments

Comments
 (0)