Explorar o código

fix(council): improve invalid preset error with actionable guidance (#228)

When an LLM hallucinates a preset name, the error message now provides
clear corrective action instead of a generic not-found message.

Closes #225
ReqX hai 2 semanas
pai
achega
e7ad05e2ee
Modificáronse 2 ficheiros con 29 adicións e 1 borrados
  1. 27 0
      src/council/council-manager.test.ts
  2. 2 1
      src/council/council-manager.ts

+ 27 - 0
src/council/council-manager.test.ts

@@ -656,6 +656,33 @@ describe('CouncilManager', () => {
       expect(result.councillorResults).toHaveLength(0);
     });
 
+    test('returns available presets when invalid preset name given', async () => {
+      const ctx = createMockContext();
+      const config = createTestCouncilConfig({
+        presets: {
+          default: {
+            alpha: { model: 'openai/gpt-5.4-mini' },
+          },
+          roled: {
+            beta: { model: 'openai/gpt-5.3-codex' },
+          },
+        },
+      });
+      const manager = new CouncilManager(ctx, config, undefined);
+
+      const result = await manager.runCouncil(
+        'test prompt',
+        'architect',
+        'parent-id',
+      );
+
+      expect(result.success).toBe(false);
+      expect(result.error).toContain('Preset "architect" does not exist');
+      expect(result.error).toContain('Omit the preset parameter');
+      expect(result.error).toContain('default, roled');
+      expect(result.councillorResults).toHaveLength(0);
+    });
+
     test('returns error when depth exceeded', async () => {
       const ctx = createMockContext();
       const config = createTestCouncilConfig();

+ 2 - 1
src/council/council-manager.ts

@@ -103,10 +103,11 @@ export class CouncilManager {
     const preset = councilConfig.presets[resolvedPreset];
 
     if (!preset) {
+      const available = Object.keys(councilConfig.presets).join(', ');
       log(`[council-manager] Preset "${resolvedPreset}" not found`);
       return {
         success: false,
-        error: `Preset "${resolvedPreset}" not found`,
+        error: `Preset "${resolvedPreset}" does not exist. Omit the preset parameter to use the default, or call again with one of: ${available}`,
         councillorResults: [],
       };
     }