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

Offen Anfängerfreundlich
#14 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
64/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
markdown
Bereich
ai, tooling

Rechercherichtung

Überprüfe skills/distill/SKILL.md, mit Schwerpunkt auf den Prompts der Sub-Agents und dem Sammlungsschritt des Koordinators. Führe /distill für einen Stapel von Konversationen aus, einschließlich genügend Sitzungen, um das Kontextlimit zu reproduzieren. Erledigt ist die Aufgabe, wenn Sub-Agents direkt in das journal schreiben, nur kurze Zusammenfassungen zurückgeben und der vollständige Distillations- und Aktualisierungsablauf ohne einen Fehler "Prompt is too long" abgeschlossen wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
TypeScript
Sterne
119
Forks
6
Ø Merge
1 Std. 32 Min.
Gemergte PRs (30 T.)
2

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus ascorbic/macrodata

Alle Issues in ascorbic/macrodata

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.