Distill skill hits "Prompt is too long" when processing many conversations
還沒有人認領這個 Issue。
評估
研究方向
檢查 skills/distill/SKILL.md,重點關注 sub-agent prompts 與 coordinator 的 collection step。針對一批對話執行 /distill,其中包括足夠多的 session 以重現 context limit。完成的標準是 sub-agents 直接寫入 journal、只回傳簡短摘要,且完整的 distillation 與 update flow 在沒有出現 "Prompt is too long" 錯誤的情況下完成。
由索引模型根據 Issue 內容生成。
描述
Problem
I have 10-25 Claude Code sessions/day. Today, the /distill skill's coordinator session started hitting "Prompt is too long" during the end-of-day/memory-maintenance runs — every API call after sub-agents completed returned this error, making the session completely unresponsive.
In my case, sub-agents were returning ~25-37KB of JSON each. With 18+ conversations to process, the accumulated results in the coordinator's context (~630KB / ~164K tokens estimated) plus the system prompt exceeded the context limit.
Root cause
Claude and I did some debugging and our understanding of the current flow is:
- Coordinator spawns sub-agents in parallel
- Each sub-agent reads a conversation, extracts JSON, returns it to the coordinator
- Coordinator collects all results, then writes to journal
Step 2 seems like the problem. All returned results accumulate in the coordinator's context. Claude Code context is append-only until compaction — there's no way to discard results between turns. The more conversations you have, the more result data piles up.
Fix attempted
Have sub-agents write directly to the journal via log_journal() instead of returning results to the coordinator. Each sub-agent returns only a short summary string (e.g., "Wrote 3 actions, 2 facts, 1 decision to journal.").
The coordinator then reads from the journal (get_recent_journal) when it needs the data for entity/state file updates.
Before: sub-agent → returns 35KB JSON → coordinator writes to journal
After: sub-agent → writes to journal directly → returns ~50 bytes
Tested
Patched locally and ran against 25 conversations without issue. Previously failed with 18 "Prompt is too long" results. All 25 conversations completed successfully — distillation, state file updates, entity updates, index maintenance finished without hitting context limits.
Proposed changes to skills/distill/SKILL.md
- Sub-agent prompt: instead of "Extract and return as JSON", instruct to call
log_journal()directly with topicsdistilled,distilled-fact,distilled-decision - Sub-agent prompt: "Return ONLY a short summary line" instead of "Return ONLY the JSON"
- Step 3 (Collect): coordinator reads from journal instead of parsing returned JSON
- Add note: "Sub-agents MUST write to journal themselves and return only a short summary"
Happy to open a PR with the full SKILL.md change if this approach looks good.
- 主要語言
- TypeScript
- 星號
- 119
- 分支
- 6
- 平均合併
- 1 小時 32 分鐘
- 30 天內合併 PR
- 2
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
ascorbic/macrodata 的其他 Issue
-
難度 1/5 1 小時以內 新手友好度 70/100
-
難度 1/5 1 小時以內 新手友好度 74/100
-
難度 2/5 1-3 小時 新手友好度 68/100
-
難度 3/5 1-2 天 新手友好度 55/100
-
Support Cursor 未關閉
難度 5/5 一週以上 新手友好度 25/100
查看 ascorbic/macrodata 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
難度 2/5 1-3 小時 新手友好度 78/100
-
enhancement
難度 2/5 1-3 小時 新手友好度 68/100
-
calcite-components needs triage refactor
難度 2/5 1-3 小時 新手友好度 75/100
Esri/calcite-design-system#15203 ·
-
難度 1/5 1 小時以內 新手友好度 78/100
fullcalendar/fullcalendar#8106 ·