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

Abierto Apto para principiantes
#14 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
64/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
markdown
Área
ai, tooling

Línea de trabajo

Revisa skills/distill/SKILL.md, centrándote en los prompts de los sub-agents y en el paso de recopilación del coordinador. Ejecuta /distill sobre un lote de conversaciones, incluyendo suficientes sesiones para reproducir el límite de contexto. Se considera completado cuando los sub-agents escriben directamente en el journal, devuelven solo resúmenes breves y todo el flujo de distillation y actualización se completa sin un error "Prompt is too long".

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
119
Forks
6
Merge medio
1 h 32 min
PR fusionados (30 d)
2

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ascorbic/macrodata

Todos los issues de ascorbic/macrodata

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.