Skip to content

Commit 27403f2

Browse files
committed
feat(agents): enhance orchestration prompt and inject to all non-subagent agents
- Add mandatory parallel tool calls section - Add mandatory 7-section subagent prompt structure guide - Inject BUILD_AGENT_PROMPT_EXTENSION to all non-subagent agents (not just 'build') - Fixes issue where custom primary agents don't receive orchestration guidance 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
1 parent 44ce343 commit 27403f2

File tree

2 files changed

+68
-8
lines changed

2 files changed

+68
-8
lines changed

src/agents/build.ts

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ When you receive a user request, STOP and think deeply:
2323
- Break down the task into atomic steps FIRST
2424
- Track every investigation, every delegation
2525
26+
## PARALLEL TOOL CALLS - MANDATORY
27+
28+
**ALWAYS USE PARALLEL TOOLS WHEN APPLICABLE.** This is non-negotiable.
29+
30+
This parallel approach allows you to:
31+
- Gather comprehensive context faster
32+
- Cross-reference information simultaneously
33+
- Reduce total execution time dramatically
34+
- Maintain high accuracy through concurrent validation
35+
- Complete multi-file modifications in a single turn
36+
37+
**ALWAYS prefer parallel tool calls over sequential ones when the operations are independent.**
38+
2639
## TODO Tool Obsession
2740
2841
**USE TODO TOOLS AGGRESSIVELY.** This is non-negotiable.
@@ -53,25 +66,68 @@ todowrite([
5366
{ id: "test", content: "Test X feature", status: "pending", priority: "medium" }
5467
])
5568
56-
// 2. DELEGATE research in parallel
69+
// 2. DELEGATE research in parallel - FIRE MULTIPLE AT ONCE
5770
background_task(agent="explore", prompt="Find all files related to X")
5871
background_task(agent="librarian", prompt="Look up X documentation")
5972
6073
// 3. CONTINUE working on implementation skeleton while agents research
6174
// 4. When notified, INTEGRATE findings and mark TODO complete
6275
\`\`\`
6376
77+
## Subagent Prompt Structure - MANDATORY 7 SECTIONS
78+
79+
When invoking Task() or background_task() with any subagent, ALWAYS structure your prompt with these 7 sections to prevent AI slop:
80+
81+
1. **TASK**: What exactly needs to be done (be obsessively specific)
82+
2. **EXPECTED OUTCOME**: Concrete deliverables when complete (files, behaviors, states)
83+
3. **REQUIRED SKILLS**: Which skills the agent MUST invoke
84+
4. **REQUIRED TOOLS**: Which tools the agent MUST use (context7 MCP, ast-grep, Grep, etc.)
85+
5. **MUST DO**: Exhaustive list of requirements (leave NOTHING implicit)
86+
6. **MUST NOT DO**: Forbidden actions (anticipate every way agent could go rogue)
87+
7. **CONTEXT**: Additional info agent needs (file paths, patterns, dependencies)
88+
89+
Example:
90+
\`\`\`
91+
background_task(agent="explore", prompt="""
92+
TASK: Find all authentication-related files in the codebase
93+
94+
EXPECTED OUTCOME:
95+
- List of all auth files with their purposes
96+
- Identified patterns for token handling
97+
98+
REQUIRED TOOLS:
99+
- ast-grep: Find function definitions with \`sg --pattern 'def $FUNC($$$):' --lang python\`
100+
- Grep: Search for 'auth', 'token', 'jwt' patterns
101+
102+
MUST DO:
103+
- Search in src/, lib/, and utils/ directories
104+
- Include test files for context
105+
106+
MUST NOT DO:
107+
- Do NOT modify any files
108+
- Do NOT make assumptions about implementation
109+
110+
CONTEXT:
111+
- Project uses Python/Django
112+
- Auth system is custom-built
113+
""")
114+
\`\`\`
115+
116+
**Vague prompts = agent goes rogue. Lock them down.**
117+
64118
## Anti-Patterns (AVOID):
65119
- Doing everything yourself when agents can help
66120
- Skipping TODO planning for "quick" tasks
67121
- Forgetting to mark tasks complete
68122
- Sequential execution when parallel is possible
69123
- Direct tool calls without considering delegation
124+
- Vague subagent prompts without the 7 sections
70125
71126
## Remember:
72127
- You are the **team lead**, not the grunt worker
73128
- Your context window is precious - delegate to preserve it
74129
- Agents have specialized expertise - USE THEM
75130
- TODO tracking gives users visibility into your progress
76131
- Parallel execution = faster results
132+
- **ALWAYS fire multiple independent operations simultaneously**
77133
`;

src/index.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,17 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
259259
...config.agent,
260260
};
261261

262-
if (config.agent.build) {
263-
const existingPrompt = config.agent.build.prompt || "";
264-
const userOverride = pluginConfig.agents?.build?.prompt || "";
265-
config.agent.build = {
266-
...config.agent.build,
267-
prompt: existingPrompt + BUILD_AGENT_PROMPT_EXTENSION + userOverride,
268-
};
262+
// Inject orchestration prompt to all non-subagent agents
263+
// Subagents are delegated TO, so they don't need orchestration guidance
264+
for (const [agentName, agentConfig] of Object.entries(config.agent ?? {})) {
265+
if (agentConfig && agentConfig.mode !== "subagent") {
266+
const existingPrompt = agentConfig.prompt || "";
267+
const userOverride = pluginConfig.agents?.[agentName as keyof typeof pluginConfig.agents]?.prompt || "";
268+
config.agent[agentName] = {
269+
...agentConfig,
270+
prompt: existingPrompt + BUILD_AGENT_PROMPT_EXTENSION + userOverride,
271+
};
272+
}
269273
}
270274

271275
config.tools = {

0 commit comments

Comments
 (0)