refactor: Hub-only gateway architecture + agent collaboration overhaul#36
Merged
yishuiliunian merged 1 commit intomainfrom Mar 28, 2026
Merged
Conversation
…overhaul Migrate from "every agent is a TCP server" to "Hub is the sole gateway, agents are pure stdio workers". This restructures the entire multi-agent communication, lifecycle management, and tool system. Hub Architecture: - Hub owns all agent connections (stdio for agents, TCP for external clients) - Agent processes no longer open TCP ports (tcp_accept.rs deleted) - Hub manages agent spawn, completion detection, and cascade shutdown - Explicit agent/completed protocol (not relying on EOF alone) - Agent topology table tracking parent/child relationships and lifecycle - Permission/question relay through Hub with 30s timeout Completion Chain (was completely broken, now reliable): - Non-interactive agent server auto-exits after session completes - Hub captures real agent output (from ToolResult/Stream events) - hub/wait_agent spawned as background task (doesn't block IO loop) - Race-safe: emit_agent_finished before unregister + finished_outputs cache - 10-minute timeout on wait_agent to prevent infinite hangs Agent Collaboration Tools (redesigned): - Agent tool: self-contained with action=spawn/result/status - SendMessage: simplified to point-to-point Hub routing only - Removed: Channel tool (unreliable pull model), TaskOutput/TaskStop tools - Bash tool: integrated background process management (process_id param) - Tools reorganized: collaboration/ subdirectory for multi-agent tools Deleted (legacy point-to-point): - MessageRouter, AgentRegistry, Channel/ChannelStore - tcp_accept.rs, bridge event forwarding - 5 hub/channel protocol methods, hub/broadcast - TaskOutputTool, TaskStopTool (merged into Bash) Bug Fixes: - Loop detector warning no longer breaks tool_use/tool_result pairing - normalize_messages ensures ToolResult blocks before Text blocks - Spawn failure cleanup (kills orphan processes) - Parent validation on agent registration
768c70c to
4d798fd
Compare
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.
Summary
Changes
Hub Architecture (loopal-agent-hub):
agent/completedprotocol (primary signal, EOF as fallback)hub/wait_agentruns as background task (no IO loop blocking)hub/agent_info,hub/topologyquery methodsAgent Tools (loopal-agent):
tools/collaboration/agent.rs: Agent tool with action=spawn/result/statustools/collaboration/send_message.rs: Point-to-point only (no broadcast/shutdown)Process Tools (tools/process):
Completion Chain Fixes:
104 files changed, +4378/-2844
Test plan
cargo clippy --workspace --tests— zero warningscargo test --workspace— 1632 tests pass