X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/2a276c273c21a1752d541bf87e074c5d1c27e30f..36229ef68a30c5a117599037d79fa1fc708fbfef:/daemon_agent_test.go diff --git a/daemon_agent_test.go b/daemon_agent_test.go index 7b1407b..3fceb34 100644 --- a/daemon_agent_test.go +++ b/daemon_agent_test.go @@ -3,6 +3,7 @@ package main import ( "context" "io" + "net/http" "os" "path/filepath" "strings" @@ -28,6 +29,15 @@ func TestDaemonOpensAndRunsTheRootAndTwoChildren(t *testing.T) { require.Len(t, agents, 3) require.Equal(t, []string{"Garden", "Library"}, agents.ChildNames()) + server.reply = func(w http.ResponseWriter, call ModelFakeCall) { + text := "" + if call.body["prompt_cache_key"] == agents[0].agent.CacheKey() { + text = "The decision is recorded." + } + + modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem(text)}, 100, 0, 5)) + } + for _, agent := range agents { at := clock.Now().Add(time.Minute).Format(scheduleAtLayout) _, err = agent.schedules.Set("Record the decision for "+agent.agent.config.Name, &at, nil) @@ -56,7 +66,13 @@ func TestDaemonOpensAndRunsTheRootAndTwoChildren(t *testing.T) { require.Eventually(t, func() bool { for _, agent := range agents { - if agent.memory.Len() != 2 { + count := 1 + if agent == agents[0] { + count = 2 + } + + usage, err := os.ReadFile(filepath.Join(agent.agent.dir, "usage.jsonl")) + if err != nil || !strings.HasSuffix(string(usage), "\n") || agent.memory.Len() != count { return false } }