Summary
Fix and complete streaming support in the autonomous loop structure (max_loops="auto"). Currently, streaming works partially during planning and execution phases but does not work in the final summary phase, breaking the end-to-end streaming experience.
The autonomous loop structure in agent.py supports three phases:
- Planning Phase ✅ - Streaming works
- Execution Phase ✅ - Streaming works
- Summary Phase ❌ - Streaming does NOT work
When users enable streaming (streaming_on=True or stream=True) with max_loops="auto", they expect continuous token streaming throughout the entire autonomous loop. However, the final summary generation happens without streaming, causing an inconsistent user experience.
Current Behavior
from swarms import Agent
# User enables streaming with autonomous loop
agent = Agent(
agent_name="TaskAgent",
system_prompt="You are a helpful assistant",
model_name="gpt-4",
max_loops="auto", # Autonomous loop enabled
streaming_on=True, # User expects streaming throughout
verbose=True
)
def on_token(token):
print(token, end="", flush=True)
# Run with streaming callback
result = agent.run(
task="Create a comprehensive marketing plan",
streaming_callback=on_token
)
# Result:
# ✅ Planning phase streams tokens
# ✅ Execution phase streams tokens
# ❌ Summary phase does NOT stream (silent until complete)
This improvement is essential for production-grade autonomous agents where real-time feedback and responsiveness are critical requirements.
Summary
Fix and complete streaming support in the autonomous loop structure (
max_loops="auto"). Currently, streaming works partially during planning and execution phases but does not work in the final summary phase, breaking the end-to-end streaming experience.The autonomous loop structure in
agent.pysupports three phases:When users enable streaming (
streaming_on=Trueorstream=True) withmax_loops="auto", they expect continuous token streaming throughout the entire autonomous loop. However, the final summary generation happens without streaming, causing an inconsistent user experience.Current Behavior
This improvement is essential for production-grade autonomous agents where real-time feedback and responsiveness are critical requirements.