diff --git a/heicode/controller/agnet_callback.go b/heicode/controller/agnet_callback.go index 3222abfb..17147e7a 100644 --- a/heicode/controller/agnet_callback.go +++ b/heicode/controller/agnet_callback.go @@ -304,6 +304,16 @@ func applyAgnetCallbackDeploymentState(payload agnetCallbackEnvelope, record agn if status != "" { record.Status = status record.RuntimeState = status + if containsString([]string{"completed", "failed", "stopped"}, status) { + for idx := range record.AgentInstances { + if record.AgentInstances[idx].RuntimeState == "" || !containsString([]string{"failed", "stopped"}, record.AgentInstances[idx].RuntimeState) { + record.AgentInstances[idx].RuntimeState = status + } + if record.Phase != "" { + record.AgentInstances[idx].Phase = record.Phase + } + } + } changed = true } case "phase.changed": diff --git a/heicode/controller/agnet_control_plane_test.go b/heicode/controller/agnet_control_plane_test.go index 88ed028c..51367e82 100644 --- a/heicode/controller/agnet_control_plane_test.go +++ b/heicode/controller/agnet_control_plane_test.go @@ -1270,15 +1270,6 @@ func TestAgnetCallbackUpdatesDeploymentRuntimeSnapshot(t *testing.T) { "occurred_at":"2026-05-28T12:41:00Z", "payload":{"stage":"deploy","checkpoint":"completed","summary":"Runtime completed"} }`) - postCallback(`{ - "event_id":"evt-runtime-agent-completed", - "event_type":"agent.completed", - "deployment_id":"swm-runtime-state-1", - "swarm_id":"swm-runtime-state-1", - "agent_instance_id":"agi-runtime-builder", - "occurred_at":"2026-05-28T12:41:30Z", - "payload":{"agent_role":"builder","status":"completed","stage":"deploy"} - }`) postCallback(`{ "event_id":"evt-runtime-status-completed", "event_type":"deployment.status_changed",