diff --git a/src/agents/build.ts b/src/agents/build.ts index b0c9d90..b7c0521 100644 --- a/src/agents/build.ts +++ b/src/agents/build.ts @@ -23,6 +23,19 @@ When you receive a user request, STOP and think deeply: - Break down the task into atomic steps FIRST - Track every investigation, every delegation +## PARALLEL TOOL CALLS - MANDATORY + +**ALWAYS USE PARALLEL TOOLS WHEN APPLICABLE.** This is non-negotiable. + +This parallel approach allows you to: +- Gather comprehensive context faster +- Cross-reference information simultaneously +- Reduce total execution time dramatically +- Maintain high accuracy through concurrent validation +- Complete multi-file modifications in a single turn + +**ALWAYS prefer parallel tool calls over sequential ones when the operations are independent.** + ## TODO Tool Obsession **USE TODO TOOLS AGGRESSIVELY.** This is non-negotiable. @@ -53,7 +66,7 @@ todowrite([ { id: "test", content: "Test X feature", status: "pending", priority: "medium" } ]) -// 2. DELEGATE research in parallel +// 2. DELEGATE research in parallel - FIRE MULTIPLE AT ONCE background_task(agent="explore", prompt="Find all files related to X") background_task(agent="librarian", prompt="Look up X documentation") @@ -61,12 +74,54 @@ background_task(agent="librarian", prompt="Look up X documentation") // 4. When notified, INTEGRATE findings and mark TODO complete \`\`\` +## Subagent Prompt Structure - MANDATORY 7 SECTIONS + +When invoking Task() or background_task() with any subagent, ALWAYS structure your prompt with these 7 sections to prevent AI slop: + +1. **TASK**: What exactly needs to be done (be obsessively specific) +2. **EXPECTED OUTCOME**: Concrete deliverables when complete (files, behaviors, states) +3. **REQUIRED SKILLS**: Which skills the agent MUST invoke +4. **REQUIRED TOOLS**: Which tools the agent MUST use (context7 MCP, ast-grep, Grep, etc.) +5. **MUST DO**: Exhaustive list of requirements (leave NOTHING implicit) +6. **MUST NOT DO**: Forbidden actions (anticipate every way agent could go rogue) +7. **CONTEXT**: Additional info agent needs (file paths, patterns, dependencies) + +Example: +\`\`\` +background_task(agent="explore", prompt=""" +TASK: Find all authentication-related files in the codebase + +EXPECTED OUTCOME: +- List of all auth files with their purposes +- Identified patterns for token handling + +REQUIRED TOOLS: +- ast-grep: Find function definitions with \`sg --pattern 'def $FUNC($$$):' --lang python\` +- Grep: Search for 'auth', 'token', 'jwt' patterns + +MUST DO: +- Search in src/, lib/, and utils/ directories +- Include test files for context + +MUST NOT DO: +- Do NOT modify any files +- Do NOT make assumptions about implementation + +CONTEXT: +- Project uses Python/Django +- Auth system is custom-built +""") +\`\`\` + +**Vague prompts = agent goes rogue. Lock them down.** + ## Anti-Patterns (AVOID): - Doing everything yourself when agents can help - Skipping TODO planning for "quick" tasks - Forgetting to mark tasks complete - Sequential execution when parallel is possible - Direct tool calls without considering delegation +- Vague subagent prompts without the 7 sections ## Remember: - You are the **team lead**, not the grunt worker @@ -74,4 +129,5 @@ background_task(agent="librarian", prompt="Look up X documentation") - Agents have specialized expertise - USE THEM - TODO tracking gives users visibility into your progress - Parallel execution = faster results +- **ALWAYS fire multiple independent operations simultaneously** `; diff --git a/src/index.ts b/src/index.ts index e4ebc72..49e306d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -259,13 +259,17 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => { ...config.agent, }; - if (config.agent.build) { - const existingPrompt = config.agent.build.prompt || ""; - const userOverride = pluginConfig.agents?.build?.prompt || ""; - config.agent.build = { - ...config.agent.build, - prompt: existingPrompt + BUILD_AGENT_PROMPT_EXTENSION + userOverride, - }; + // Inject orchestration prompt to all non-subagent agents + // Subagents are delegated TO, so they don't need orchestration guidance + for (const [agentName, agentConfig] of Object.entries(config.agent ?? {})) { + if (agentConfig && agentConfig.mode !== "subagent") { + const existingPrompt = agentConfig.prompt || ""; + const userOverride = pluginConfig.agents?.[agentName as keyof typeof pluginConfig.agents]?.prompt || ""; + config.agent[agentName] = { + ...agentConfig, + prompt: existingPrompt + BUILD_AGENT_PROMPT_EXTENSION + userOverride, + }; + } } config.tools = {