From 0f0cb7e08eeaa41b12fb6dea24517b61e6a79ffd Mon Sep 17 00:00:00 2001 From: catlog22 Date: Fri, 16 Jan 2026 15:36:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=20brainstorm=20?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87=E6=BA=A2=E5=87=BA=E4=BF=9D=E6=8A=A4?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - conceptual-planning-agent.md: 34行 → 10行(-71%) - auto-parallel.md: 42行 → 9行(-79%) - 消除重复定义,workflow 引用 agent 限制 - 移除冗余的策略列表、自检清单、代码示例 - 保留核心功能:限制数字、简要策略、恢复方法 --- .claude/agents/conceptual-planning-agent.md | 37 ++++-------------- .../workflow/brainstorm/auto-parallel.md | 39 ++----------------- 2 files changed, 11 insertions(+), 65 deletions(-) diff --git a/.claude/agents/conceptual-planning-agent.md b/.claude/agents/conceptual-planning-agent.md index b4afc473..5e4e0bff 100644 --- a/.claude/agents/conceptual-planning-agent.md +++ b/.claude/agents/conceptual-planning-agent.md @@ -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 diff --git a/.claude/commands/workflow/brainstorm/auto-parallel.md b/.claude/commands/workflow/brainstorm/auto-parallel.md index 14183836..fd315509 100644 --- a/.claude/commands/workflow/brainstorm/auto-parallel.md +++ b/.claude/commands/workflow/brainstorm/auto-parallel.md @@ -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