Fix oMLX OOM stalls in Pi agent by adding a "reduce context" compact trigger

chibop1 · reddit · 2026-08-18

When running oMLX with the Pi agent, long sessions frequently hit out-of-memory errors and the agent simply stops — even with Memory guard set to aggressive and a sane context length — forcing manual compaction and resume.

The author's fix adds a compaction trigger word to Pi: clone the omlx repo, edit packages/ai/src/utils/overflow.ts, and below the line /token limit exceeded/i add /reduce context/i, then reinstall with npm install && npm run build and npm install -g ./packages/coding-agent.

The trick works because oMLX sends a stop error containing the phrase "reduce context" on context-related problems, so Pi now compacts regardless of the configured context length. The result: qwen-3.8-27b runs for hours overnight without intervention.

Original post →

More from coding & agent

coding & agent channel →