last := subagentTestLastItem(call)
switch {
case subagentTestCall(call) && last["type"] == "function_call_output":
- // The report comes after the reply of the turn of the spawn.
+ // The report comes after the reply of the turn of the
+ // spawn.
test.events.WaitFor(t, "reply", 1)
modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("There are 3 files.")}, 100, 0, 5))
case subagentTestCall(call):
"work: " + report,
"reply: Noted.",
}, test.Log(t))
+
require.Equal(t, Event{
Kind: "work",
ID: 4,
Source: name,
Status: subagentFinished,
}, test.events.LastEvent("work"))
+
require.Equal(t, "<6>subagent started name="+name+"\n<6>subagent done name="+name+" after=0s\n", test.logs.String())
var first, second *ModelFakeCall
"work: [" + name + "]\nfailed: create model response: model call: HTTP 400: " + subagentTestFullContext + "\n\nFull chat: zoom(\"" + name + "\")",
"reply: It failed.",
}, test.Log(t))
+
require.Equal(t, subagentFailed, test.events.LastEvent("work").Status)
require.Equal(t, "<6>subagent started name="+name+"\n<3>subagent failed name="+name+" after=0s: create model response: model call: HTTP 400: "+subagentTestFullContext+"\n", test.logs.String())
}
"note: Stopped by the user: " + name + ".",
"work: " + subagentReport(name, []string{"stopped"}),
}, test.Log(t))
+
require.Equal(t, subagentStopped, test.events.LastEvent("work").Status)
require.Equal(t, "<6>subagent started name="+name+"\n<6>subagent stopped name="+name+" after=0s\n", test.logs.String())
"work: " + subagentReport("BlueFox", []string{"failed: no agent BlueFox"}),
"reply: a line",
}, subagentTestChat(t, memory))
+
require.Equal(t, subagentFailed, events.LastEvent("work").Status)
require.Equal(t, "<3>subagent lost at restart name=BlueFox: no agent BlueFox\n", logs.String())
}
// subagentTestStart runs a loop of agent with its memory and subagents in the
-// agent directory, as the daemon does. The returned function stops the loop
-// and closes the files.
+// agent directory, as the daemon does. The returned function stops the loop and
+// closes the files.
func subagentTestStart(t *testing.T, agent *Agent, server *ModelFake, events *TurnEventRecorder, logger *slog.Logger) (*TurnLoop, *Memory, func()) {
t.Helper()
}
}
-// subagentTestChat returns each message of the chat in memory as
-// "kind: text".
+// subagentTestChat returns each message of the chat in memory as "kind: text".
func subagentTestChat(t *testing.T, memory *Memory) []string {
t.Helper()
return input[len(input)-1].(map[string]any)
}
-// subagentTestText returns the text of the user message item, or "" for
-// another item.
+// subagentTestText returns the text of the user message item, or "" for another
+// item.
func subagentTestText(item map[string]any) string {
content, _ := item["content"].([]any)