summaryrefslogtreecommitdiff
path: root/internal/config/config_test.go
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-04-28 17:10:27 +0000
committerClaude <noreply@anthropic.com>2026-04-28 17:10:27 +0000
commitae833b2765c7c8086bf8e1ea8e8ec8ee9b73e656 (patch)
treeb2cda4dc982d6c04eb22033e19645091af42224b /internal/config/config_test.go
parent0865afc43be562dbe14528e4299b9e213b54cc93 (diff)
feat(api): route elaboration through local LLM when configured
Phase 2 of "local OSS models as agents" plan. Adds a third elaboration path that calls the local OpenAI-compatible LLM via the internal/llm client, and reorders dispatch so the cheap path is tried first: local → claude → gemini, with each next attempt only on hard failure of the prior. Wiring is opt-out, not opt-in: when [local_model].endpoint is set, elaboration prefers local by default. Users with a slow or low-quality local model can disable just elaboration via: [local_model] endpoint = "..." prefer_for_elaborate = false without giving up the runner or the classifier path. Implementation: - Server gains an optional *llm.Client field via SetLLM (matches the existing SetNotifier/SetWorkspaceRoot setter pattern, no NewServer signature break). - elaborateWithLocal() reuses buildElaboratePrompt verbatim and asks for response_format=json_object so we skip markdown-fence cleanup. - handleElaborateTask reorders try chain; existing Claude-first behavior is preserved exactly when SetLLM is not called. - LocalModel.UseForElaborate() encapsulates the default-true gating with a *bool so explicit-false survives TOML parse. Tests: - elaborateWithLocal: parses valid response, errors on nil client, errors on bad JSON. - handler: local preferred when wired; falls back to claude when local fails; unchanged behavior when no LLM is configured. - config: UseForElaborate gating across empty/default/explicit-true/ explicit-false cases. Pre-existing test failures noted in docs/plans/local-oss-runner.md (post-epic cleanup): TestGeminiLogs_ParsedCorrectly returns 404 for gemini execution log fetch — predates this change. Plan: docs/plans/local-oss-runner.md. https://claude.ai/code/session_017Edeq947TpSm1vQTxMhi1J
Diffstat (limited to 'internal/config/config_test.go')
-rw-r--r--internal/config/config_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/config/config_test.go b/internal/config/config_test.go
index 2bba2c4..e4f1a5d 100644
--- a/internal/config/config_test.go
+++ b/internal/config/config_test.go
@@ -53,3 +53,33 @@ func TestLoadFile_MissingFile_ReturnsError(t *testing.T) {
t.Fatal("expected error for missing file, got nil")
}
}
+
+func TestLocalModel_UseForElaborate_EmptyEndpoint(t *testing.T) {
+ m := LocalModel{}
+ if m.UseForElaborate() {
+ t.Error("empty endpoint should never opt into elaborate")
+ }
+}
+
+func TestLocalModel_UseForElaborate_DefaultTrue(t *testing.T) {
+ m := LocalModel{Endpoint: "http://localhost:11434/v1"}
+ if !m.UseForElaborate() {
+ t.Error("endpoint set + default flag should opt in")
+ }
+}
+
+func TestLocalModel_UseForElaborate_ExplicitFalse(t *testing.T) {
+ f := false
+ m := LocalModel{Endpoint: "http://localhost:11434/v1", PreferForElaborate: &f}
+ if m.UseForElaborate() {
+ t.Error("explicit false should opt out")
+ }
+}
+
+func TestLocalModel_UseForElaborate_ExplicitTrue(t *testing.T) {
+ tr := true
+ m := LocalModel{Endpoint: "http://localhost:11434/v1", PreferForElaborate: &tr}
+ if !m.UseForElaborate() {
+ t.Error("explicit true should opt in")
+ }
+}