From 2ee988ccc04c09ceb6de7cdb75c94114e85d01b9 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Sat, 14 Mar 2026 00:39:22 +0000 Subject: feat: add agent selector to UI and support direct agent assignment - Added an agent selector (Auto, Claude, Gemini) to the Start Next Task button. - Updated the backend to pass query parameters as environment variables to scripts. - Modified the executor pool to skip classification when a specific agent is requested. - Added --agent flag to claudomator start command. - Updated tests to cover the new functionality. --- internal/executor/executor_test.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'internal/executor/executor_test.go') diff --git a/internal/executor/executor_test.go b/internal/executor/executor_test.go index 7e676eb..17982f8 100644 --- a/internal/executor/executor_test.go +++ b/internal/executor/executor_test.go @@ -1121,3 +1121,41 @@ func TestPool_LoadBalancing_OverridesAgentType(t *testing.T) { t.Errorf("expected claude runner to be called once, got %d", runner.callCount()) } } + +// TestPool_SpecificAgent_SkipsLoadBalancing verifies that if a specific +// registered agent is requested (claude or gemini), it is used directly +// and load balancing (pickAgent) is skipped. +func TestPool_SpecificAgent_SkipsLoadBalancing(t *testing.T) { + store := testStore(t) + claudeRunner := &mockRunner{} + geminiRunner := &mockRunner{} + runners := map[string]Runner{ + "claude": claudeRunner, + "gemini": geminiRunner, + } + logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelError})) + pool := NewPool(4, runners, store, logger) + + // Inject 2 active tasks for gemini, 0 for claude. + // pickAgent would normally pick "claude". + pool.mu.Lock() + pool.activePerAgent["gemini"] = 2 + pool.mu.Unlock() + + tk := makeTask("specific-gemini") + tk.Agent.Type = "gemini" + store.CreateTask(tk) + + if err := pool.Submit(context.Background(), tk); err != nil { + t.Fatalf("submit: %v", err) + } + + <-pool.Results() + + if geminiRunner.callCount() != 1 { + t.Errorf("expected gemini runner to be called once, got %d", geminiRunner.callCount()) + } + if claudeRunner.callCount() != 0 { + t.Errorf("expected claude runner to NOT be called, got %d", claudeRunner.callCount()) + } +} -- cgit v1.2.3