diff --git a/cameleer3-server-app/src/main/java/com/cameleer3/server/app/agent/SseConnectionManager.java b/cameleer3-server-app/src/main/java/com/cameleer3/server/app/agent/SseConnectionManager.java index 65506d26..6c575643 100644 --- a/cameleer3-server-app/src/main/java/com/cameleer3/server/app/agent/SseConnectionManager.java +++ b/cameleer3-server-app/src/main/java/com/cameleer3/server/app/agent/SseConnectionManager.java @@ -3,7 +3,9 @@ package com.cameleer3.server.app.agent; import com.cameleer3.server.app.config.AgentRegistryConfig; import com.cameleer3.server.core.agent.AgentCommand; import com.cameleer3.server.core.agent.AgentEventListener; +import com.cameleer3.server.core.agent.AgentInfo; import com.cameleer3.server.core.agent.AgentRegistryService; +import com.cameleer3.server.core.runtime.RuntimeOrchestrator; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.annotation.PostConstruct; @@ -35,13 +37,16 @@ public class SseConnectionManager implements AgentEventListener { private final AgentRegistryConfig config; private final SsePayloadSigner ssePayloadSigner; private final ObjectMapper objectMapper; + private final RuntimeOrchestrator runtimeOrchestrator; public SseConnectionManager(AgentRegistryService registryService, AgentRegistryConfig config, - SsePayloadSigner ssePayloadSigner, ObjectMapper objectMapper) { + SsePayloadSigner ssePayloadSigner, ObjectMapper objectMapper, + RuntimeOrchestrator runtimeOrchestrator) { this.registryService = registryService; this.config = config; this.ssePayloadSigner = ssePayloadSigner; this.objectMapper = objectMapper; + this.runtimeOrchestrator = runtimeOrchestrator; } @PostConstruct @@ -81,6 +86,13 @@ public class SseConnectionManager implements AgentEventListener { }); log.info("SSE connection established for agent {}", agentId); + + // Stop container log capture — agent is now online and will send its own logs + AgentInfo agent = registryService.findById(agentId); + if (agent != null) { + runtimeOrchestrator.stopLogCaptureByApp(agent.applicationId(), agent.environmentId()); + } + return emitter; }