fix: complete sub callback agent state

This commit is contained in:
gongzhiyong
2026-05-28 21:30:53 +08:00
parent 8e7bdc6388
commit fecb365e87
2 changed files with 10 additions and 9 deletions
+10
View File
@@ -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":
@@ -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",