Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Shadow Agent Architecture for Broadcast Responses
Summary
ask_others()without interrupting parent agentsMotivation
The previous broadcast implementation interrupted agents mid-stream to handle
ask_others()requests, causing:The shadow agent architecture solves these issues by:
asyncio.gather()without blocking parent agentsvote/new_answer)Changes
New Files
massgen/shadow_agent.py- Shadow agent spawner implementation with:ShadowAgentSpawnerclass for spawning and managing shadow agents_build_current_turn_context()to capture full streaming context--debugflag is usedModified Files
massgen/_broadcast_channel.py- Added_spawn_shadow_agents()method for parallel shadow spawningmassgen/chat_agent.py- Added current turn context tracking:_current_turn_content- text content_current_turn_tool_calls- native tool calls_current_turn_reasoning- reasoning/thinking chunks_current_turn_mcp_calls- MCP tool calls with args/resultsmassgen/tool/workflow_toolkits/broadcast.py- Simplified;respond_to_broadcastnow deprecateddocs/source/user_guide/advanced/agent_communication.rst- Updated documentationRemoved
chat_agent.py_broadcast_queue,inject_broadcast,_check_broadcast_queuemethods_handle_broadcast,_handle_broadcast_inline,_handle_broadcast_backgroundmethodsHow It Works
ask_others("What framework should we use?")Debug Mode
Use
--debugflag to save shadow agent context:uv run massgen --config massgen/configs/broadcast/test_broadcast_agents.yaml --debug "..."Debug files saved to:
.massgen/massgen_logs/<session>/shadow_agents/Contains:
current_turn_context.formatted- string passed to shadowcurrent_turn_context.raw- detailed breakdown (content, tool_calls, reasoning, mcp_calls)Test Plan