diff --git a/packages/core/src/agents/teamRegistry.ts b/packages/core/src/agents/teamRegistry.ts index 97185619b2..30faf3ad42 100644 --- a/packages/core/src/agents/teamRegistry.ts +++ b/packages/core/src/agents/teamRegistry.ts @@ -86,8 +86,16 @@ export class TeamRegistry { // Register team agents in the global AgentRegistry so they are available as SubagentTools for (const agent of team.agents) { + const descriptionOverride = `MANDATORY for ${agent.displayName} tasks: ${agent.description} (Team Agent: ${team.displayName}). You MUST delegate all ${agent.displayName} tasks to this agent.`; + + // We wrap the agent definition to provide the description override + const wrappedAgent = { + ...agent, + description: descriptionOverride, + }; + registrationPromises.push( - this.agentRegistry.registerAgent(agent).catch((e) => { + this.agentRegistry.registerAgent(wrappedAgent).catch((e) => { debugLogger.warn( `[TeamRegistry] Error registering agent "${agent.name}" from team "${team.name}":`, e, diff --git a/packages/core/src/prompts/promptProvider.ts b/packages/core/src/prompts/promptProvider.ts index e0b6105cbc..1fe97a0893 100644 --- a/packages/core/src/prompts/promptProvider.ts +++ b/packages/core/src/prompts/promptProvider.ts @@ -181,6 +181,7 @@ export class PromptProvider { taskTracker: trackerDir, topicUpdateNarration: context.config.isTopicUpdateNarrationEnabled(), + activeTeam: context.config.getActiveTeam(), }), !isPlanMode, ), diff --git a/packages/core/src/prompts/snippets.legacy.ts b/packages/core/src/prompts/snippets.legacy.ts index 4fea88937b..a768412d92 100644 --- a/packages/core/src/prompts/snippets.legacy.ts +++ b/packages/core/src/prompts/snippets.legacy.ts @@ -5,6 +5,7 @@ */ import type { HierarchicalMemory } from '../config/memory.js'; +import { type TeamDefinition } from '../agents/types.js'; import { ACTIVATE_SKILL_TOOL_NAME, ASK_USER_TOOL_NAME, @@ -62,9 +63,11 @@ export interface PrimaryWorkflowsOptions { enableCodebaseInvestigator: boolean; enableWriteTodosTool: boolean; enableEnterPlanModeTool: boolean; + enableGrep: boolean; + enableGlob: boolean; approvedPlan?: { path: string }; taskTracker?: string; - topicUpdateNarration?: boolean; + activeTeam?: TeamDefinition; } export interface OperationalGuidelinesOptions { @@ -249,11 +252,16 @@ export function renderPrimaryWorkflows( options?: PrimaryWorkflowsOptions, ): string { if (!options) return ''; + + const teamMandate = options.activeTeam + ? `\n\n**Team Orchestration Mandate:** You are orchestrating the **${options.activeTeam.displayName}**. You MUST NOT perform implementation, review, or testing tasks yourself. You MUST delegate these specialized tasks to the appropriate team-member sub-agents.` + : ''; + return ` # Primary Workflows ## Software Engineering Tasks -When requested to perform tasks like fixing bugs, adding features, refactoring, or explaining code, follow this sequence: +When requested to perform tasks like fixing bugs, adding features, refactoring, or explaining code, follow this sequence:${teamMandate} ${workflowStepUnderstand(options)} ${workflowStepPlan(options)} 3. **Implement:** Use the available tools (e.g., '${EDIT_TOOL_NAME}', '${WRITE_FILE_TOOL_NAME}' '${SHELL_TOOL_NAME}' ...) to act on the plan. Strictly adhere to the project's established conventions (detailed under 'Core Mandates'). Before making manual code changes, check if an ecosystem tool (like 'eslint --fix', 'prettier --write', 'go fmt', 'cargo fmt') is available in the project to perform the task automatically. diff --git a/packages/core/src/prompts/snippets.ts b/packages/core/src/prompts/snippets.ts index 116635fe6f..482c3ca0f5 100644 --- a/packages/core/src/prompts/snippets.ts +++ b/packages/core/src/prompts/snippets.ts @@ -78,6 +78,7 @@ export interface PrimaryWorkflowsOptions { approvedPlan?: { path: string }; taskTracker?: string; topicUpdateNarration: boolean; + activeTeam?: TeamDefinition; } export interface OperationalGuidelinesOptions { @@ -126,10 +127,10 @@ export function getCoreSystemPrompt(options: SystemPromptOptions): string { return ` ${renderPreamble(options.preamble)} -${renderCoreMandates(options.coreMandates)} - ${renderActiveTeam(options.activeTeam)} +${renderCoreMandates(options.coreMandates)} + ${renderSubAgents(options.subAgents)} ${renderAgentSkills(options.agentSkills)} @@ -344,11 +345,15 @@ export function renderPrimaryWorkflows( ? `\n\n**State Transition Override:** You are now in **Execution Mode**. All previous "Read-Only", "Plan Mode", and "ONLY FOR PLANS" constraints are **immediately lifted**. You are explicitly authorized and required to use tools to modify source code and environment files to implement the approved plan. Begin executing the steps of the plan immediately.` : ''; + const teamMandate = options.activeTeam + ? `\n\n**Team Orchestration Mandate:** You are orchestrating the **${options.activeTeam.displayName}**. You MUST NOT perform implementation, review, or testing tasks yourself. You MUST delegate these specialized tasks to the appropriate team-member sub-agents.` + : ''; + return ` # Primary Workflows ## Development Lifecycle -Operate using a **Research -> Strategy -> Execution** lifecycle. For the Execution phase, resolve each sub-task through an iterative **Plan -> Act -> Validate** cycle.${transitionOverride} +Operate using a **Research -> Strategy -> Execution** lifecycle. For the Execution phase, resolve each sub-task through an iterative **Plan -> Act -> Validate** cycle.${transitionOverride}${teamMandate} ${workflowStepResearch(options)} ${workflowStepStrategy(options)}