Skip to content

fix: include external memory in sandbox OOM detection#34

Open
ntegrals wants to merge 1 commit intomasterfrom
fix/sandbox-memory-monitoring
Open

fix: include external memory in sandbox OOM detection#34
ntegrals wants to merge 1 commit intomasterfrom
fix/sandbox-memory-monitoring

Conversation

@ntegrals
Copy link
Copy Markdown
Owner

@ntegrals ntegrals commented Apr 2, 2026

Summary

The sandbox's OOM detection only checked RSS memory, missing external memory (native addon allocations, Buffers, graphics memory from Playwright/Chromium). For long-running agents, external memory can grow unbounded without triggering OOM — the process gets killed by the OS instead of gracefully shutting down.

Changes

OOM detection — now checks RSS + external against the limit instead of RSS alone. This catches memory growth from:

  • Playwright's CDP protocol buffers
  • Screenshot data (sharp image processing)
  • Chromium's internal allocations exposed via process.memoryUsage().external

New metricpeakExternalMB added to SandboxMetrics so callers can see the native memory breakdown:

const result = await sandbox.run({ task, model });
console.log(result.metrics.peakMemoryMB);    // RSS peak
console.log(result.metrics.peakExternalMB);  // External/native peak

Files changed

File Change
sandbox/src/sandbox.ts Track peakExternalMB, check rss + external for OOM
sandbox/src/types.ts Add peakExternalMB to SandboxMetrics

Test plan

  • bun run build — all 3 packages compile clean
  • bun run test — all 364 tests pass

OOM check now monitors RSS + external memory (native buffers, graphics)
instead of RSS alone. Adds peakExternalMB to SandboxMetrics for
visibility into native memory consumption.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants