Преглед изворни кода

fix(council): limit council_session to council agent

Alvin Unreal пре 4 месеци
родитељ
комит
052aea70dc
4 измењених фајлова са 18 додато и 21 уклоњено
  1. 2 2
      src/agents/index.test.ts
  2. 1 1
      src/agents/index.ts
  3. 12 15
      src/tools/council.test.ts
  4. 3 3
      src/tools/council.ts

+ 2 - 2
src/agents/index.test.ts

@@ -129,11 +129,11 @@ describe('orchestrator agent', () => {
     expect((orchestrator?.config.permission as any).question).toBe('allow');
   });
 
-  test('orchestrator is allowed to invoke council_session', () => {
+  test('orchestrator is denied access to council_session', () => {
     const agents = createAgents();
     const orchestrator = agents.find((a) => a.name === 'orchestrator');
     expect((orchestrator?.config.permission as any).council_session).toBe(
-      'allow',
+      'deny',
     );
   });
 

+ 1 - 1
src/agents/index.ts

@@ -31,7 +31,7 @@ type AgentFactory = (
   customAppendPrompt?: string,
 ) => AgentDefinition;
 
-const COUNCIL_TOOL_ALLOWED_AGENTS = new Set(['orchestrator', 'council']);
+const COUNCIL_TOOL_ALLOWED_AGENTS = new Set(['council']);
 
 function normalizeDisplayName(displayName: string): string {
   const trimmed = displayName.trim();

+ 12 - 15
src/tools/council.test.ts

@@ -359,23 +359,20 @@ describe('council_session tool', () => {
       expect(councilManager.runCouncil).toHaveBeenCalledTimes(1);
     });
 
-    test('allows orchestrator agent to invoke council session', async () => {
+    test('blocks orchestrator agent from invoking council session', async () => {
       const ctx = createMockPluginContext();
-      const councilManager = createMockCouncilManager({
-        success: true,
-        result: 'Synthesised answer',
-        councillorResults: [
-          { name: 'alpha', status: 'completed', result: 'A' },
-        ],
-      });
+      const councilManager = createMockCouncilManager();
       const tools = createCouncilTool(ctx, councilManager);
 
-      const result = await tools.council_session.execute({ prompt: 'Test' }, {
-        sessionID: 'test',
-        agent: 'orchestrator',
-      } as any);
-
-      expect(result).toContain('Synthesised answer');
+      expect(
+        tools.council_session.execute({ prompt: 'Test' }, {
+          sessionID: 'test',
+          agent: 'orchestrator',
+        } as any),
+      ).rejects.toThrow(
+        'Council sessions can only be invoked by the council agent',
+      );
+      expect(councilManager.runCouncil).not.toHaveBeenCalled();
     });
 
     test('blocks disallowed agents from invoking council session', async () => {
@@ -389,7 +386,7 @@ describe('council_session tool', () => {
           agent: 'explorer',
         } as any),
       ).rejects.toThrow(
-        'Council sessions can only be invoked by council or orchestrator agents',
+        'Council sessions can only be invoked by the council agent',
       );
       expect(councilManager.runCouncil).not.toHaveBeenCalled();
     });

+ 3 - 3
src/tools/council.ts

@@ -58,13 +58,13 @@ Returns the councillor responses with a summary footer.`,
         throw new Error('Invalid toolContext: missing sessionID');
       }
 
-      // Guard: Only council and orchestrator agents can invoke council sessions.
+      // Guard: Only the council agent can invoke council sessions.
       // If agent is missing from context, allow through (backward compatible).
-      const allowedAgents = ['council', 'orchestrator'];
+      const allowedAgents = ['council'];
       const callingAgent = (toolContext as { agent?: string }).agent;
       if (callingAgent && !allowedAgents.includes(callingAgent)) {
         throw new Error(
-          `Council sessions can only be invoked by council or orchestrator agents. Current agent: ${callingAgent}`,
+          `Council sessions can only be invoked by the council agent. Current agent: ${callingAgent}`,
         );
       }