diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-08 20:50:21 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-08 20:50:21 +0000 |
| commit | 406247b14985ab57902e8e42898dc8cb8960290d (patch) | |
| tree | 4a93be793f541038dd5d3fc154563051ba151b50 /internal/executor/classifier_test.go | |
| parent | 0ff0bf75544bbf565288e61bb8e10c3f903830f8 (diff) | |
feat(executor): implement Gemini-based task classification and load balancing
- Add Classifier using gemini-2.0-flash-lite to automatically select agent/model.
- Update Pool to track per-agent active tasks and rate limit status.
- Enable classification for all tasks (top-level and subtasks).
- Refine SystemStatus to be dynamic across all supported agents.
- Add unit tests for the classifier and updated pool logic.
- Minor UI improvements for project selection and 'Start Next' action.
Diffstat (limited to 'internal/executor/classifier_test.go')
| -rw-r--r-- | internal/executor/classifier_test.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/internal/executor/classifier_test.go b/internal/executor/classifier_test.go new file mode 100644 index 0000000..4de44ca --- /dev/null +++ b/internal/executor/classifier_test.go @@ -0,0 +1,49 @@ +package executor + +import ( + "context" + "os" + "testing" +) + +// TestClassifier_Classify_Mock tests the classifier with a mocked gemini binary. +func TestClassifier_Classify_Mock(t *testing.T) { + // Create a temporary mock binary. + mockBinary := filepathJoin(t.TempDir(), "mock-gemini") + mockContent := `#!/bin/sh +echo '{"agent_type": "gemini", "model": "gemini-2.0-flash", "reason": "test reason"}' +` + if err := os.WriteFile(mockBinary, []byte(mockContent), 0755); err != nil { + t.Fatal(err) + } + + c := &Classifier{GeminiBinaryPath: mockBinary} + status := SystemStatus{ + ActiveTasks: map[string]int{"claude": 5, "gemini": 1}, + RateLimited: map[string]bool{"claude": false, "gemini": false}, + } + + cls, err := c.Classify(context.Background(), "Test Task", "Test Instructions", status) + if err != nil { + t.Fatalf("Classify failed: %v", err) + } + + if cls.AgentType != "gemini" { + t.Errorf("expected gemini, got %s", cls.AgentType) + } + if cls.Model != "gemini-2.0-flash" { + t.Errorf("expected gemini-2.0-flash, got %s", cls.Model) + } +} + +func filepathJoin(elems ...string) string { + var path string + for i, e := range elems { + if i == 0 { + path = e + } else { + path = path + string(os.PathSeparator) + e + } + } + return path +} |
