]> git.giacomolli.uk - onechat/blobdiff - subagent_run_test.go
Check the complete message before committing
[onechat] / subagent_run_test.go
index 389a4bf2d56ce11ff3c589f0a835fafb03d33e76..30fcc78fdae947d4f724443ed7aa36590e443dfb 100644 (file)
@@ -531,6 +531,35 @@ func TestRestartReportsASubagentThatCannotGoOn(t *testing.T) {
        require.JSONEq(t, `{"running": []}`, string(data))
 }
 
+// subagentTestLastItem returns the last input item of call.
+func subagentTestLastItem(call ModelFakeCall) map[string]any {
+       input := call.body["input"].([]any)
+
+       return input[len(input)-1].(map[string]any)
+}
+
+// subagentTestCall tells if call is a call of a subagent.
+func subagentTestCall(call ModelFakeCall) bool {
+       instructions, _ := call.body["instructions"].(string)
+
+       return strings.HasPrefix(instructions, "You are a subagent")
+}
+
+// subagentTestText returns the text of the user message item, or "" for another
+// item.
+func subagentTestText(item map[string]any) string {
+       content, _ := item["content"].([]any)
+
+       var text strings.Builder
+
+       for _, part := range content {
+               value, _ := part.(map[string]any)["text"].(string)
+               text.WriteString(value)
+       }
+
+       return text.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.
@@ -577,32 +606,3 @@ func subagentTestChat(t *testing.T, memory *Memory) []string {
 
        return lines
 }
-
-// subagentTestCall tells if call is a call of a subagent.
-func subagentTestCall(call ModelFakeCall) bool {
-       instructions, _ := call.body["instructions"].(string)
-
-       return strings.HasPrefix(instructions, "You are a subagent")
-}
-
-// subagentTestLastItem returns the last input item of call.
-func subagentTestLastItem(call ModelFakeCall) map[string]any {
-       input := call.body["input"].([]any)
-
-       return input[len(input)-1].(map[string]any)
-}
-
-// subagentTestText returns the text of the user message item, or "" for another
-// item.
-func subagentTestText(item map[string]any) string {
-       content, _ := item["content"].([]any)
-
-       var text strings.Builder
-
-       for _, part := range content {
-               value, _ := part.(map[string]any)["text"].(string)
-               text.WriteString(value)
-       }
-
-       return text.String()
-}