summaryrefslogtreecommitdiff
path: root/internal/executor/nativerunner_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/executor/nativerunner_test.go')
-rw-r--r--internal/executor/nativerunner_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/internal/executor/nativerunner_test.go b/internal/executor/nativerunner_test.go
index ab0317c..b081b8e 100644
--- a/internal/executor/nativerunner_test.go
+++ b/internal/executor/nativerunner_test.go
@@ -199,6 +199,44 @@ func TestNativeRunner_Run_ToolLoop_ReportSummaryAndSpawn(t *testing.T) {
}
}
+// TestNativeRunner_Run_ToolLoop_SpawnSubtask_RolePassthrough is an
+// end-to-end-ish test (fake LLM server, real agentloop.Loop/tools.go
+// dispatch, real storeChannel) proving a spawn_subtask tool call carrying a
+// "role" argument reaches SubtaskSpec.Role correctly through
+// internal/agentloop/tools.go's dispatchTool, and from there through
+// storeChannel.SpawnSubtask into the created child task's Agent.Role.
+func TestNativeRunner_Run_ToolLoop_SpawnSubtask_RolePassthrough(t *testing.T) {
+ srv := fakeChatServer(t, []fakeTurn{
+ {toolCalls: []llm.ToolCall{toolCall("c1", "spawn_subtask", `{"name":"eval","instructions":"evaluate","role":"evaluator_quality"}`)}},
+ {content: "finished"},
+ })
+ defer srv.Close()
+
+ r := newLocalRunner(t, srv)
+ tt := localTask()
+ store := &fakeChannelStore{}
+ ch := newStoreChannel(store, tt.ID)
+ exec := &storage.Execution{ID: uuid.New().String(), TaskID: tt.ID}
+
+ if err := r.Run(context.Background(), tt, exec, ch); err != nil {
+ t.Fatalf("Run: %v", err)
+ }
+
+ if len(store.createdTasks) != 1 {
+ t.Fatalf("expected 1 spawned subtask, got %d", len(store.createdTasks))
+ }
+ child := store.createdTasks[0]
+ if child.Agent.Role != "evaluator_quality" {
+ t.Errorf("Agent.Role: want evaluator_quality, got %q", child.Agent.Role)
+ }
+ if child.Agent.Type != "" {
+ t.Errorf("Agent.Type: want empty for role-typed subtask, got %q", child.Agent.Type)
+ }
+ if child.Agent.Instructions != "evaluate" {
+ t.Errorf("Agent.Instructions: want evaluate, got %q", child.Agent.Instructions)
+ }
+}
+
func TestNativeRunner_Run_RecordProgress(t *testing.T) {
srv := fakeChatServer(t, []fakeTurn{
{toolCalls: []llm.ToolCall{toolCall("c1", "record_progress", `{"message":"halfway there"}`)}},