Accept a late parent terminal event in the child process page
ci / vet-and-test (pull_request) Successful in 1m2s
ci / vet-and-test (pull_request) Successful in 1m2s
Why: waitRunTerminal can return before run.completed is stored, so that event may land between the appended tool output and the child events. Evidence: CI run 3274 failed twice on TestRunProcessEventsAreOrderedAndBoundToConversation with run.completed ahead of the child progress and result. Local go test of that test passed after this assertion. Impact: the test still rejects leaked child tool output and still requires child progress then result, in that order. Refs: Agent-System-Backend pulls/201 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user