sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

[BUG] Proper error handling for Swarm agent if the agent response is timed out

Open Julia-Bobo-Hu opened this issue 1 year ago • 2 comments

Checks

  • [x] I have updated to the lastest minor and patch version of Strands
  • [x] I have checked the documentation and this is not expected behavior
  • [x] I have searched ./issues and there are no duplicates of my issue

Strands Version

1.0.1

Python Version

3.10.4

Operating System

macOS

Installation Method

pip

Steps to Reproduce

  1. install strands agent, 2. run the 09 example from the use cases, https://github.com/strands-agents/samples/tree/main/02-samples/09-finance-assistant-swarm-agent 3. here is the error message: ERROR | strands.multiagent.swarm | node=<company_strategist>, timeout=<60.0>s | node execution timed out after timeout Traceback (most recent call last): File "/home/ec2-user/anaconda3/lib/python3.12/asyncio/tasks.py", line 520, in wait_for return await fut ^^^^^^^^^ File "/home/ec2-user/SageMaker/strands-main-review/02-samples/09-finance-assistant-swarm-agent/.venv/lib/python3.12/site-packages/strands/multiagent/swarm.py", line 590, in _execute_node result = await node.executor.invoke_async(node_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ec2-user/SageMaker/strands-main-review/02-samples/09-finance-assistant-swarm-agent/.venv/lib/python3.12/site-packages/strands/agent/agent.py", line 398, in invoke_async async for event in events: File "/home/ec2-user/SageMaker/strands-main-review/02-samples/09-finance-assistant-swarm-agent/.venv/lib/python3.12/site-packages/strands/agent/agent.py", line 508, in stream_async async for event in events: File "/home/ec2-user/SageMaker/strands-main-review/02-samples/09-finance-assistant-swarm-agent/.venv/lib/python3.12/site-packages/strands/agent/agent.py", line 544, in _run_loop async for event in events: File "/home/ec2-user/SageMaker/strands-main-review/02-samples/09-finance-assistant-swarm-agent/.venv/lib/python3.12/site-packages/strands/agent/agent.py", line 583, in _execute_event_loop_cycle async for event in events: File "/home/ec2-user/SageMaker/strands-main-review/02-samples/09-finance-assistant-swarm-agent/.venv/lib/python3.12/site-packages/strands/event_loop/event_loop.py", line 132, in event_loop_cycle async for event in stream_messages(agent.model, agent.system_prompt, agent.messages, tool_specs): File "/home/ec2-user/SageMaker/strands-main-review/02-samples/09-finance-assistant-swarm-agent/.venv/lib/python3.12/site-packages/strands/event_loop/streaming.py", line 318, in stream_messages async for event in process_stream(chunks): File "/home/ec2-user/SageMaker/strands-main-review/02-samples/09-finance-assistant-swarm-agent/.venv/lib/python3.12/site-packages/strands/event_loop/streaming.py", line 273, in process_stream async for chunk in chunks: File "/home/ec2-user/SageMaker/strands-main-review/02-samples/09-finance-assistant-swarm-agent/.venv/lib/python3.12/site-packages/strands/models/bedrock.py", line 344, in stream event = await queue.get() ^^^^^^^^^^^^^^^^^ File "/home/ec2-user/anaconda3/lib/python3.12/asyncio/queues.py", line 158, in get await getter asyncio.exceptions.CancelledError

The above exception was the direct cause of t

Expected Behavior

The call is timed out, but it should either retry or handle the error gracefully.

Actual Behavior

Showed timeout error message under this situation.

Additional Context

No response

Possible Solution

No response

Related Issues

No response

Julia-Bobo-Hu avatar Jul 29 '25 04:07 Julia-Bobo-Hu

hi @Julia-Bobo-Hu are you still encountering this issue? i see you have updated the sample to use the latest version of Swarm from the SDK and i am wondering if you are still experiencing the error.

jer96 avatar Aug 07 '25 19:08 jer96

hi @Julia-Bobo-Hu i'll be closing this issue due to inactivity, please reopen is the issue persists.

jer96 avatar Aug 14 '25 14:08 jer96