Aulafy
Courses/Agents and automation/OOM and memory management

OOM and memory management

Many agents work in demos but fail in production because they accumulate tool results, API responses, and long conversations within the same context.

  • Identify why OOM occurs in agents and long-running workflows.
  • Separate context, persistent state, logs, and heavy results.
  • Apply limits, queues, and alerts before the system dies without explanation.

Common causes

  • Storing complete tool responses in the agent state.
  • Putting entire documents into context instead of chunks and references.
  • Retries that duplicate messages, results, and traces.
  • n8n workflows running in a single process without separate workers.
  • Huge buffers instead of streaming or batch processing.
TerminalCode
politica_memoria:
  max_tool_result_chars: 6000
  guardar_en_contexto:
    - resumen
    - ids
    - citas
  guardar_fuera:
    - html completo
    - pdf extraido
    - respuestas api largas
  si_supera_limite:
    - persistir_blob
    - resumir
    - enlazar_por_id
    - continuar