diff --git a/internal/server/run_process_events_test.go b/internal/server/run_process_events_test.go index c879d6d..d65527a 100644 --- a/internal/server/run_process_events_test.go +++ b/internal/server/run_process_events_test.go @@ -70,8 +70,24 @@ func TestRunProcessEventsAreOrderedAndBoundToConversation(t *testing.T) { t.Fatalf("child page: %d %v", code, childPage) } childRows := childPage["events"].([]any) - if len(childRows) != 2 || childRows[0].(map[string]any)["type"] != string(core.EvAgentProgress) || childRows[1].(map[string]any)["type"] != string(core.EvAgentResult) { - t.Fatalf("child progress/result not retained or raw child output leaked: %v", childRows) + var childTypes []string + for _, row := range childRows { + ev := row.(map[string]any) + typ, _ := ev["type"].(string) + if typ == string(core.EvToolOutput) { + payload, _ := ev["payload"].(map[string]any) + if payload["text"] == "child raw output" { + t.Fatalf("raw child output leaked: %v", childRows) + } + } + if typ == string(core.EvAgentProgress) || typ == string(core.EvAgentResult) { + childTypes = append(childTypes, typ) + } + } + // 父运行的终态事件可能在 waitRunTerminal 之后才落库,序号会落在这次追加的 + // 工具输出和子运行事件之间。这里只要求子运行进度与结果按序保留。 + if len(childTypes) != 2 || childTypes[0] != string(core.EvAgentProgress) || childTypes[1] != string(core.EvAgentResult) { + t.Fatalf("child progress/result not retained: types=%v rows=%v", childTypes, childRows) } code, _ = doJSON(t, h, http.MethodGet, "/api/conversations/"+otherConvID+"/runs/"+runID+"/events", nil) if code != http.StatusNotFound {