refactor: 优化 brainstorm 上下文溢出保护文档

- conceptual-planning-agent.md: 34行 → 10行(-71%)
- auto-parallel.md: 42行 → 9行(-79%)
- 消除重复定义,workflow 引用 agent 限制
- 移除冗余的策略列表、自检清单、代码示例
- 保留核心功能:限制数字、简要策略、恢复方法
This commit is contained in:
catlog22
2026-01-16 15:36:59 +08:00
parent 39d070eab6
commit 0f0cb7e08e
2 changed files with 11 additions and 65 deletions

View File

@@ -308,37 +308,14 @@ When analysis is complete, ensure:
- **Relevance**: Directly addresses user's specified requirements
- **Actionability**: Provides concrete next steps and recommendations
## Output Size Limits (Context Overflow Prevention)
## Output Size Limits
**⚠️ CRITICAL**: To prevent API context overflow in brainstorm workflows, enforce these limits:
**Per-role limits** (prevent context overflow):
- `analysis.md`: < 3000 words
- `analysis-*.md`: < 2000 words each (max 5 sub-documents)
- Total: < 15000 words per role
### Document Size Limits
- `analysis.md` (main): **< 3000 words** (~12KB)
- `analysis-*.md` (sub-docs): **< 2000 words each** (~8KB)
- Maximum 5 sub-documents per role
- **Total per-role**: **< 15000 words** (~60KB)
**Strategies**: Be concise, use bullet points, reference don't repeat, prioritize top 3-5 items, defer details
### Strategies for Staying Within Limits
1. **Be concise**: Focus on key insights, not exhaustive detail
2. **Use bullet points**: More efficient than prose paragraphs
3. **Reference don't repeat**: Use `@filename.md` references instead of duplicating content
4. **Prioritize**: Include top 3-5 recommendations per section, not all possible ones
5. **Defer details**: Mark "further analysis needed" for complex areas instead of expanding
### Self-Check Before Output
```
Before writing files, verify:
□ Main analysis.md < 3000 words
□ Each sub-document < 2000 words
□ Total sub-documents ≤ 5
□ No duplicated content across files
□ References used where appropriate
```
### If Limit Exceeded
If analysis naturally exceeds limits:
1. Split into essential vs nice-to-have content
2. Move nice-to-have to a separate `analysis-appendix.md` (counts toward 5 sub-doc limit)
3. Use executive summary style for main document
4. Note "detailed analysis available on request" for deferred topics
**If exceeded**: Split essential vs nice-to-have, move extras to `analysis-appendix.md` (counts toward limit), use executive summary style

View File

@@ -428,44 +428,13 @@ CONTEXT_VARS:
## Context Overflow Protection
**⚠️ IMPORTANT**: Brainstorm workflows can generate substantial content across multiple roles. To prevent API context limit issues:
**Per-role limits**: See `conceptual-planning-agent.md` (< 3000 words main, < 2000 words sub-docs, max 5 sub-docs)
### Per-Role Output Limits
- Each `analysis.md` should be **< 3000 words**
- Sub-documents (`analysis-*.md`) should be **< 2000 words each**
- Maximum 5 sub-documents per role
- Total per-role content: **< 15000 words**
**Synthesis protection**: If total analysis > 100KB, synthesis reads only `analysis.md` files (not sub-documents)
### Synthesis Phase Protection
Before Phase 3 (synthesis), check total analysis size:
```javascript
// Check combined analysis size before synthesis
const analysisFiles = Glob(".workflow/active/WFS-{session}/.brainstorming/*/analysis*.md");
let totalSize = 0;
for (const file of analysisFiles) {
totalSize += getFileSize(file);
}
**Recovery**: Check logs → reduce scope (--count 2) → use --summary-only → manual synthesis
// If total > 100KB, use summary mode
if (totalSize > 100 * 1024) {
console.log("⚠️ Large context detected. Using summary mode for synthesis.");
// Synthesis will read only analysis.md (index) files, not sub-documents
useSummaryMode = true;
}
```
### Recovery from Context Overflow
If API returns empty response or timeout:
1. **Identify overflow**: Check last request size in logs
2. **Reduce scope**: Re-run synthesis with fewer roles (use `--count 2`)
3. **Use summary mode**: Pass `--summary-only` to synthesis command
4. **Manual synthesis**: Combine key insights from each role's `analysis.md` manually
### Prevention Best Practices
- Start with `--count 3` (default) before trying more roles
- Use structured topic format: `"GOAL: [x] SCOPE: [y] CONTEXT: [z]"`
- Review each role's output size before proceeding to synthesis
- For complex topics, consider running brainstorm in phases (3 roles at a time)
**Prevention**: Start with --count 3, use structured topic format, review output sizes before synthesis
## Reference Information