From 99c4fdc52f165c2199905ac4785ab6a408a6d6b1 Mon Sep 17 00:00:00 2001 From: Alex Korin Date: Wed, 24 Dec 2025 13:29:09 +0000 Subject: [PATCH] Fix: Add missing Docker labels to system agent container The system agent was missing required Docker labels (trinity.ssh-port, trinity.cpu, trinity.memory, trinity.created), causing port allocation conflicts when creating new agents. Without trinity.ssh-port label: - get_agent_status_from_container() returns port=0 - get_next_available_port() filters out port 0 - System agent's port (2290) appears available - New agents fail with 'port already allocated' error This fix adds all required labels to match the standard agent creation pattern in routers/agents.py, ensuring proper port tracking and conflict prevention. --- src/backend/services/system_agent_service.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/services/system_agent_service.py b/src/backend/services/system_agent_service.py index 91a33d535..ce7e4745f 100644 --- a/src/backend/services/system_agent_service.py +++ b/src/backend/services/system_agent_service.py @@ -225,9 +225,12 @@ async def _create_system_agent(self) -> dict: 'trinity.platform': 'agent', 'trinity.agent-name': SYSTEM_AGENT_NAME, 'trinity.agent-type': agent_type, + 'trinity.ssh-port': str(ssh_port), # Required for port tracking + 'trinity.cpu': str(resources.get('cpu', '4')), + 'trinity.memory': resources.get('memory', '8g'), + 'trinity.created': datetime.utcnow().isoformat(), 'trinity.template': SYSTEM_AGENT_TEMPLATE, 'trinity.is-system': 'true', # Mark as system agent - 'trinity.created-at': datetime.utcnow().isoformat() } # Create the container