Skip to content

TUI crashes with JavaScript heap OOM during long agentic sessions (25+ tool-call steps) #121

Description

@gokcanakalin

SUMMARY:
Environment: Windows 11 Home, PowerShell 7, atomic-agent v0.1.72, cloud mode (DeepSeek via OpenRouter)

Trigger: Single turn with 25 agentic steps reading large source files

Error: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory at ~4GB V8 heap
NDJSON trace, text export, and screenshot attached

Root cause: TUI retains full conversation + tool outputs in React/Ink state without conversation windowing or pruning

FULL:

The atomic-agent crashed with a
JavaScript heap out of memory (OOM) error after approximately 25+
tool-call steps and 40+ minutes of operation. The crash was caused by
unbounded growth of the conversation state in the agent's TUI, which
retained full conversation history, tool outputs, and internal state
without pruning.

Root Cause:
The atomic-agent's TUI (built with React/Ink) does not implement
conversation windowing or pruning. As the session progresses, the
agent accumulates:

  • All user messages
  • All agent responses (including internal reasoning)
  • All tool outputs (including large JSON responses from MCP servers)
  • Internal state (token counts, timing, model metadata)

This results in monotonic memory growth, eventually exhausting the
default 4GB Node.js V8 heap limit.

Evidence from Sanitized Trace:
The sanitized NDJSON trace (trace-sanitized.ndjson) shows:

  • 215 total events spanning ~2400 seconds
  • Monotonic increase in token counts across events (prompt_tokens,
    completion_tokens)
  • Tool outputs growing in size (e.g., web_search results, web_fetch
    content, file reads)
  • Final events show token counts in the tens of thousands before crash
  • The crash event (FATAL ERROR) occurs after event #215

Specifically, the trace reveals that the agent's internal state
includes full copies of:

  • Web search results (snippets, URLs)
  • Web fetched content (full markdown/text)
  • File contents (when using read_file or similar)
  • Tool invocation details (parameters, results)

Impact:

  • Loss of the current agent session, requiring restart
  • Potential loss of unsaved work if not persisted elsewhere
  • Need to re-establish context after restart
  • Disruption to any ongoing automated tasks

Attachments:

  1. trace-sanitized.ndjson - Sanitized NDJSON trace (215 events, all PII removed)
  2. powershell-crash-sanitized.txt - Sanitized PowerShell crash output
    (GC logs, FATAL ERROR, stack trace)
  3. screenshot-sanitized.png - Sanitized screenshot of the agent TUI at
    crash time

powershell-crash-sanitized.txt
Image
trace-sanitized.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions