with open('autonomous_swarm.py', 'r') as f:
    content = f.read()

# Replace the entire CoordinatorAgent __init__ correctly
old = '''class CoordinatorAgent(BaseAgent):
    def __init__(self, agents):
        super().__init__("Coordinator", "coordinating the agent swarm")
        self.swarm = swarm
        self.agents = agents'''

new = '''class CoordinatorAgent(BaseAgent):
    def __init__(self, swarm=None):
        super().__init__("Coordinator", "coordinating the agent swarm")
        self.swarm = swarm
        self.agents = swarm.agents if swarm else []'''

content = content.replace(old, new)

with open('autonomous_swarm.py', 'w') as f:
    f.write(content)

print("✅ Fixed CoordinatorAgent properly")
