Browse Source

fix(agents): allow arbitrary custom orchestrator prompts

Remove the hard requirement that a custom agent's orchestratorPrompt must start with its internal agent name. Keep the field user-authored and update tests/docs to reflect that behavior.
Alvin Unreal 3 months ago
parent
commit
5533a7553d
3 changed files with 5 additions and 17 deletions
  1. 0 1
      docs/configuration.md
  2. 5 3
      src/agents/custom.test.ts
  3. 0 13
      src/agents/index.ts

+ 0 - 1
docs/configuration.md

@@ -185,5 +185,4 @@ Notes:
 
 - Custom agent names must be safe identifiers such as `janitor` or `security-reviewer`
 - Custom agents without a `model` are skipped with a warning
-- `orchestratorPrompt` must begin with the matching `@agent-name`
 - Disabled custom agents are not registered or injected into the orchestrator prompt

+ 5 - 3
src/agents/custom.test.ts

@@ -109,7 +109,7 @@ describe('custom-agent creation', () => {
     expect(() => createAgents(config)).toThrow();
   });
 
-  test('requires orchestratorPrompt to start with the custom agent mention', () => {
+  test('accepts arbitrary orchestratorPrompt text for custom agents', () => {
     const config: PluginConfig = {
       agents: {
         janitor: {
@@ -119,8 +119,10 @@ describe('custom-agent creation', () => {
       },
     };
 
-    expect(() => createAgents(config)).toThrow(
-      "Custom agent 'janitor' orchestratorPrompt must start with '@janitor'",
+    const agents = createAgents(config);
+    const orchestrator = agents.find((agent) => agent.name === 'orchestrator');
+    expect(orchestrator?.config.prompt).toContain(
+      '@cleanup\n- Role: Cleanup specialist',
     );
   });
 });

+ 0 - 13
src/agents/index.ts

@@ -107,18 +107,6 @@ function hasCustomAgentModel(
   return !Array.isArray(override.model) || override.model.length > 0;
 }
 
-function validateCustomAgentOverride(
-  name: string,
-  override: AgentOverrideConfig,
-): void {
-  const orchestratorPrompt = override.orchestratorPrompt?.trim();
-  if (orchestratorPrompt && !orchestratorPrompt.startsWith(`@${name}`)) {
-    throw new Error(
-      `Custom agent '${name}' orchestratorPrompt must start with '@${name}'`,
-    );
-  }
-}
-
 function buildCustomAgentDefinition(
   name: string,
   override: AgentOverrideConfig,
@@ -287,7 +275,6 @@ export function createAgents(config?: PluginConfig): AgentDefinition[] {
       return [];
     }
 
-    validateCustomAgentOverride(name, override);
     const customPrompts = loadAgentPrompt(name, config?.preset);
 
     return [