examples/workflows/multiagent_realtime/README.md
This example demonstrates how to use AgentScope's ChatRoom class to create a multi-agent real-time voice interaction system where two AI agents can have autonomous conversations without user input.
The example uses:
ChatRoom: Manages multiple RealtimeAgent instancesRealtimeAgent: Handles real-time voice interaction with AI modelsDashScopeRealtimeModel: DashScope's Qwen3-Omni realtime modelPython Dependencies:
pip install agentscope[dashscope]
pip install fastapi uvicorn
DashScope API Key:
export DASHSCOPE_API_KEY="your-api-key-here"
Start the Server:
python run_server.py
Open the Web Interface:
http://localhost:8000 in your web browserConfigure Agents:
Start the Conversation:
Stop the Conversation:
/ws/{user_id}/{session_id}client_session_create event with agent configurationsRealtimeAgent instances with specified names and instructionsChatRoom with both agentssession_created eventChatRoom automatically broadcasts messages between agentsclient_session_end event to stop the conversationScriptProcessorNode for streaming playback at 24kHzThe ChatRoom class manages multiple RealtimeAgent instances:
Each RealtimeAgent:
To use a different model, modify the DashScopeRealtimeModel configuration in run_server.py:
model=DashScopeRealtimeModel(
model_name="your-model-name",
api_key=os.getenv("DASHSCOPE_API_KEY"),
)
To add more agents, modify the agent creation section in run_server.py:
agent3 = RealtimeAgent(
name=agent3_name,
sys_prompt=agent3_instructions,
model=DashScopeRealtimeModel(
model_name="qwen3-omni-flash-realtime",
api_key=os.getenv("DASHSCOPE_API_KEY"),
),
)
chat_room = ChatRoom(agents=[agent1, agent2, agent3])
And update the frontend to include configuration fields for the additional agents.