Distill skill hits "Prompt is too long" when processing many conversations

未關閉 適合新手
#14 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
64/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
停滯
技術堆疊
markdown
領域
ai, tooling

研究方向

檢查 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:

  1. Coordinator spawns sub-agents in parallel
  2. Each sub-agent reads a conversation, extracts JSON, returns it to the coordinator
  3. 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

  1. Sub-agent prompt: instead of "Extract and return as JSON", instruct to call log_journal() directly with topics distilled, distilled-fact, distilled-decision
  2. Sub-agent prompt: "Return ONLY a short summary line" instead of "Return ONLY the JSON"
  3. Step 3 (Collect): coordinator reads from journal instead of parsing returned JSON
  4. 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

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

ascorbic/macrodata 的其他 Issue

查看 ascorbic/macrodata 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。