Browse Source

fix: add ACP wrapper model fallback

alvinreal 1 month ago
parent
commit
eaa298950c
2 changed files with 37 additions and 2 deletions
  1. 35 1
      src/agents/custom.test.ts
  2. 2 1
      src/agents/index.ts

+ 35 - 1
src/agents/custom.test.ts

@@ -1,5 +1,5 @@
 import { describe, expect, spyOn, test } from 'bun:test';
-import type { PluginConfig } from '../config';
+import { DEFAULT_MODELS, type PluginConfig } from '../config';
 import { createAgents, getAgentConfigs } from './index';
 
 describe('custom-agent creation', () => {
@@ -152,6 +152,40 @@ describe('custom-agent creation', () => {
     expect(orchestrator?.config.prompt).toContain('@claude-research');
   });
 
+  test('falls back to oracle model for ACP wrappers', () => {
+    const defaults = {
+      fixer: DEFAULT_MODELS.fixer,
+      librarian: DEFAULT_MODELS.librarian,
+      orchestrator: DEFAULT_MODELS.orchestrator,
+    };
+    DEFAULT_MODELS.fixer = undefined;
+    DEFAULT_MODELS.librarian = undefined;
+    DEFAULT_MODELS.orchestrator = undefined;
+
+    try {
+      const config: PluginConfig = {
+        acpAgents: {
+          bridge: {
+            command: 'bridge-acp',
+            args: [],
+            env: {},
+            timeoutMs: 300000,
+            permissionMode: 'ask',
+          },
+        },
+      };
+
+      const agents = createAgents(config);
+      const wrapper = agents.find((agent) => agent.name === 'bridge');
+
+      expect(wrapper?.config.model).toBe(DEFAULT_MODELS.oracle);
+    } finally {
+      DEFAULT_MODELS.fixer = defaults.fixer;
+      DEFAULT_MODELS.librarian = defaults.librarian;
+      DEFAULT_MODELS.orchestrator = defaults.orchestrator;
+    }
+  });
+
   test('rejects acpAgents that conflict with custom agents', () => {
     const config: PluginConfig = {
       agents: {

+ 2 - 1
src/agents/index.ts

@@ -71,7 +71,8 @@ function buildAcpAgentDefinition(
         config.wrapperModel ??
         DEFAULT_MODELS.fixer ??
         DEFAULT_MODELS.librarian ??
-        DEFAULT_MODELS.orchestrator,
+        DEFAULT_MODELS.orchestrator ??
+        DEFAULT_MODELS.oracle,
       temperature: 0,
       prompt,
       permission: {