Long-run resource growth: five compounding defects (TUI repaint storms, quadratic provider streaming, roster rebuilds, kernel snapshots, child retention) #2264
Dmatut7
started this conversation in
Bug reports
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
A cluster of defects that compound into the "runs for hours, then the machine crawls" report. All verified on
main(fb2db8ee1); all fixed on our downstream line with tests; we can upstream any of them.1. TUI: OSC 133 markers accumulate without bound.
assistant-message.ts:198-199(and siblings) decorate the memoized lines array in place — every frame adds another layer of escape sequences. After 200 frames a single line measured 1661 chars (should be a constant 69); in inline mode the diff then misjudges the first user message as changed and repaints the whole screen every frame. On our line: cache the decorated result by source-array identity, never mutate it (toy scene: rewritten lines 8800 → 243).2. Provider streaming is quadratic. Every chunk re-parses the full accumulated tool-call arguments (
JSON.parseper chunk ⇒ O(L²)); OpenRouter does the same withJSON.stringifyon reasoning_details. Fix: incremental parse throttle + encode once at stream end.3. Daemon
flushRosterrebuilds the world per session event (cron I/O + per-session statSync + full stringify). Fix: incremental rebuild — measured 500 sessions: 1.83s → 0.02s.4. Kernel state snapshot re-serializes the whole namespace every turn. Fix: dirty tracking + skip unchanged names (plus a final-flush fast path on dispose).
5. RLM child accounting retains full sessions + kernels. Completed subagents keep their AgentSession and a live
python -m rlm.repluntil the parent dies (measured 0.27-2GB for 10 children, held ≥90min);subagentSnapshots/completedSnapshotsgrow unbounded. Fix: bounded snapshots + idle eviction + versioned venv GC.The set is exactly what you see on a machine that has hosted agents for days: TUI gets slow first (1+2), then the daemon burns CPU (3), then memory goes (4+5). Happy to send focused PRs per cluster. Full report with file:line against your tree: https://github.com/Dmatut7/prime-agent-rlm/blob/merge/repl-kernel/docs/fork/upstream-feedback-20260911.md
All reactions