Skip to content

Commit 2a4e69b

Browse files
feat(prompt): add concurrency discipline guidance for sub-agent spawning (#86)
LLM agents could spawn excessive parallel sub-agents on complex tasks, wasting resources and tokens. Rather than hard-coding limits in the runtime, guide the LLM via system prompt to self-regulate concurrency based on task complexity — start small, assess before parallelizing, iterate instead of pre-allocating, and match parallelism to actual task breadth.
1 parent fa85fa9 commit 2a4e69b

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

crates/loopal-prompt-system/prompts/tools/agent-guidelines.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,28 @@ You can spawn sub-agents to handle tasks autonomously. Each agent runs in its ow
1010

1111
## When to Spawn
1212

13-
- **Parallel independent tasks**: Multiple searches, analyses, or implementations that don't depend on each other — launch multiple agents in one message
13+
- **Parallel independent tasks**: Multiple searches, analyses, or implementations that don't depend on each other
1414
- **Deep codebase exploration**: Use an `explore` agent (read-only, optimized for search) to investigate large or unfamiliar areas
1515
- **Architecture planning**: Use a `plan` agent (read-only) to design implementation approaches
1616
- **Protecting context**: Offload research-heavy work to keep your main context focused
1717

1818
## When NOT to Spawn
1919

2020
- Trivial tasks you can do in one or two tool calls
21-
- Tasks that need your accumulated conversation context (sub-agents start fresh or with a directive)
21+
- Tasks that need your accumulated conversation context (sub-agents start fresh)
2222
- Sequential single-file changes where continuity matters
23+
- When you already have enough information to proceed directly
24+
25+
## Concurrency Discipline
26+
27+
**Prefer fewer, focused agents over many parallel ones.** Each agent consumes an OS process, LLM context, and tokens. Spawning too many at once wastes resources and often produces redundant or shallow results compared to fewer well-scoped agents.
28+
29+
Scale concurrency to task complexity:
30+
- **Start small.** Default to the minimum number of agents that covers the task. A single well-prompted agent often outperforms several vague ones.
31+
- **Assess before parallelizing.** Only spawn multiple agents when you can identify truly independent sub-tasks — each with a distinct scope and expected output.
32+
- **Iterate, don't pre-allocate.** Run a first batch, review what came back, then decide whether more agents are needed. Avoid spawning "just in case."
33+
- **Avoid redundant exploration.** Don't split one search across many explore agents — give one agent a comprehensive, well-scoped prompt instead. Reserve multiple explore agents for genuinely separate areas of the codebase.
34+
- **Consider the cost.** A complex multi-area refactoring may justify several parallel agents; a focused bug investigation rarely does. Match the parallelism to the real breadth of the work.
2335

2436
## Agent Types
2537

@@ -32,5 +44,4 @@ You can spawn sub-agents to handle tasks autonomously. Each agent runs in its ow
3244
- Sub-agent results are NOT shown to the user — you must summarize what was found or accomplished.
3345
- Always include a short description (3-5 words) when spawning.
3446
- For open-ended research, use `explore` type. For implementation, use default.
35-
- Launch multiple independent agents simultaneously for maximum efficiency.
3647
- Trust agent outputs generally, but verify critical findings before acting on them.

0 commit comments

Comments
 (0)