A Coding Implementation Showcasing ClawTeam’s Multi-Agent Swarm Orchestration with OpenAI Function Calling
SWARM_TOOLS = [ { "type": "function", "function": { "name": "task_update", "description": "Update the status of a task. Use 'in_progress' when starting, 'completed' when done.", "parameters": { "type": "object", "properties": { "task_id": {"type": "string", "description": "The task ID"}, "status": {"type": "string", "enum": ["in_progress", "completed", "failed"]}, "result": {"type": "string", "description": "Result or output of the task"}, }, "required": ["task_id", "status"], }, }, }, { "type": "function", "function": { "name": "inbox_send", "description": "Send a message to another agent (e.g., 'leader' or a worker name).", "parameters": { "type": "object", "properties": { "to": {"type": "string", "description": "Recipient agent name"}, "message": {"type": "string", "description": "Message content"}, }, "required": ["to", "message"], }, }, }, { "type": "function", "function": { "name": "inbox_receive", "description": "Check and consume all messages in your inbox.", "parameters": { "type": "object", "properties": {}, }, }, }, { "type": "function", "function": { "name": "task_list", "description": "List tasks assigned to you or all team tasks.", "parameters": { "type": "object", "properties": { "owner": {"type": "string", "description": "Filter by owner name (optional)"}, }, }, }, }, ] class SwarmAgent: def __init__( self, name: str, role: str, system_prompt: str, task_board: TaskBoard, inbox: InboxSystem, registry: TeamRegistry, ): self.name = name self.role = role self.system_prompt = system_prompt self.task_board = task_board self.inbox = inbox self.registry = registry self.conversation_history: list = [] self.inbox.register(name) self.registry.register(name, role) def _build_system_prompt(self) -> str: coord_protocol = f""" ## Coordination Protocol (auto-injected — you are agent '{self.name}') You are part of an AI agent swarm.