Distill skill hits "Prompt is too long" when processing many conversations
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 64/100
Research direction
Review skills/distill/SKILL.md, focusing on the sub-agent prompts and the coordinator's collection step. Run /distill against a batch of conversations, including enough sessions to reproduce the context limit. Done means sub-agents write directly to the journal, return only short summaries, and the full distillation and update flow completes without a "Prompt is too long" error.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- TypeScript
- Stars
- 119
- Forks
- 6
- Avg merge
- 1h 32m
- Merged PRs (30d)
- 2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ascorbic/macrodata
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
Difficulty 1/5 Under an hour Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Support Cursor Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in ascorbic/macrodata
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100