name: Swarm Orchestration
This skill defines a pattern for an orchestrator agent to spawn, track, and control multiple sub-agent instances (a "swarm") using tmux for environment isolation and command-line interfaces supporting session resumption.
tmux installed on the host system.-conversation="<ID>").Create a tmux session with multiple windows or panes, depending on the desired layout.
Windows Layout (Clean separation & Isolation):
tmux new-session -d -s <session_name> -n agent_1 -c /path/to/isolated/dir1 tmux new-window -t <session_name> -n agent_2 -c /path/to/isolated/dir2 ...
Using -c with tmux new-window allows isolating the working directory of each agent.
Send execution commands to the specific windows.
tmux send-keys -t <session_name>:<window_name> "/path/to/cli --args" C-m
Store the mapping of Window -> Session ID if session resumption is needed.
To automate communication, use a file-based message bus.
Create a directory swarm_framework/ in the project root:
comms/requests/: For dropping request files.comms/responses/: For reading results.orchestrator.py: The polling script.bootstrap.sh: The setup script.agents/: Contains isolated directories for each agent.Request File (request_<id>.json):
{
"request_id": "req_123",
"sender": "master",
"target_agent": "orchestrator",
"prompt": "Your instruction here",
"response_file": "swarm_framework/comms/responses/res_123.json"
}
Response File (res_123.json):
{
"request_id": "req_123",
"status": "success",
"output": "... captured terminal output ..."
}
For status updates and alerts not tied to a specific request-response cycle:
Master Notifications (comms/master_notifications.json):
[
{
"timestamp": 1234567890.123,
"type": "hanging|prompt",
"agent": "grid.x",
"message": "..."
}
]Sub-agent Approval Alerts:
grid.0).===RESULT=== and ===END_RESULT=== markers to allow the system to extract the raw result and remove UI garbage.To support decentralized and scalable communication, agents use dedicated directories within their isolated folder in agents/:
incoming/: For messages from other agents.output/: For messages to other agents.archive/: For processed incoming messages.Files in output/ must follow the pattern: to_{target}_{msg_id}.json.
target: The target agent name (e.g., agent_2, orchestrator).msg_id: A unique identifier for the message.output/ directory as a .tmp file and renames it to .json when complete..json file, extracts the target, and moves the file to the target agent's incoming/ directory, renaming it to from_{source}_{msg_id}.json.incoming/, moves it to archive/, and notifies the agent via tmux send-keys to read the file.The orchestrator maps tmux window/pane names (e.g., grid.1) to directory names (e.g., agent_1) using a mapping function to ensure correct file routing.
To maintain clear boundaries and prevent Master Agent overload, the following rules are enforced by orchestrator.py:
comms/master_notifications.json.Ensure all request files populate the "sender" field!