chore(core): finalize hardened agent team orchestration logic

- Move active team instructions to top of system prompt
- Inject explicit Team Orchestration Mandate into Primary Workflows
- Make team-based sub-agent tool descriptions MANDATORY
- Use extremely aggressive delegation policies in sample teams
- Fix compilation and lint errors in snippets
This commit is contained in:
Taylor Mullen
2026-04-01 16:38:51 -07:00
parent 25c1ed21e6
commit 3b2708bbc8
4 changed files with 28 additions and 6 deletions
+9 -1
View File
@@ -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,
@@ -181,6 +181,7 @@ export class PromptProvider {
taskTracker: trackerDir,
topicUpdateNarration:
context.config.isTopicUpdateNarrationEnabled(),
activeTeam: context.config.getActiveTeam(),
}),
!isPlanMode,
),
+10 -2
View File
@@ -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.
+8 -3
View File
@@ -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)}