X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/6c7859cfea123479aba046614ee81028651ddaf5..42b4acd4ba70d3c12da4513d139717e592eefe4a:/daemon_message_test.go?ds=sidebyside diff --git a/daemon_message_test.go b/daemon_message_test.go index b401eb7..0ef67fc 100644 --- a/daemon_message_test.go +++ b/daemon_message_test.go @@ -780,6 +780,37 @@ func TestNotificationBatchesStayOrderedForEachChild(t *testing.T) { } } +func TestChildNotificationReportsOnlyItsFinalReplyToTheRoot(t *testing.T) { + server := newModelFake(t) + server.reply = func(w http.ResponseWriter, call ModelFakeCall) { + reply := "" + if call.body["model"] == "gpt-test-garden" { + reply = "A result needs the user." + } + + modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem(reply)}, 100, 0, 5)) + } + + test := newDaemonMessageTest(t, t.TempDir(), server) + test.Start(t, 0, 1, 2) + + _, err := test.messages.Notify(&NotifyInput{ + AgentID: test.agents[1].agent.config.ID, + Source: "check", + ID: "report", + Text: "Private child event data.", + }) + require.NoError(t, err) + test.events[1].WaitFor(t, "idle", 1) + test.events[0].WaitFor(t, "idle", 1) + require.Equal(t, 2, server.Calls()) + require.Equal(t, "[Garden] A result needs the user.", test.events[0].Last("work")) + require.Equal(t, 1, test.events[0].Count("work")) + require.Equal(t, notifySource, test.events[1].LastEvent("work").Source) + require.Zero(t, test.agents[2].memory.Len()) + require.Empty(t, test.Queue(t).Pending) +} + func TestParentMessageWakesChildAndFinalReplyWakesParent(t *testing.T) { server := newModelFake(t) server.reply = func(w http.ResponseWriter, call ModelFakeCall) {