Skip to content

fix(agents): prevent completed background processes from exhausting gateway memory - #115760

Merged
steipete merged 1 commit into
mainfrom
codex/s29-bash-process-retention-105625
Jul 29, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/s29-bash-process-retention-105625

Conversation

@steipete-oai

Copy link
Copy Markdown
Contributor

Closes #105625

What Problem This Solves

Fixes an issue where users running many background shell commands could leave an unbounded number of completed processes and their complete logs in Gateway memory. Resetting or deleting a conversation also left its finished command results visible until the retention timer expired.

Why This Change Was Made

Retain at most 50 completed sessions and 2,000,000 aggregate output characters, evicting the oldest completed records while preserving every retained full process log and the newest result. Session reset and deletion purge only completed results for the retired requested, canonical, and session-id scopes; running commands, unrelated conversations, and intentionally shared scopes remain intact. The process registry is imported only by the existing session-lifecycle cleanup path. No configuration, environment, protocol, database, or security-owner surface is added.

User Impact

Background-command bursts no longer produce unbounded completed-process memory growth. Users can continue to inspect complete recent command output with process list, poll, and log; resetting or deleting a conversation immediately removes only that conversation's completed command results.

Evidence

AI-assisted; independently reproduced against main before changing production code and reviewed with gpt-5.6-sol at xhigh reasoning.

  • Before fix: the real exec tool launched 53 actual Node.js child processes and retained all 53 completed results; the expected bound is 50. Actual Gateway sessions.reset and sessions.delete both retained completed results for the retired requested alias, canonical session key, and session id.
  • After fix: Linux Blacksmith Testbox run 30433732698 completed 93/93 relevant tests across 10 files and three Vitest project shards, including the same 53 actual Node subprocesses, user-visible process list/poll/log, actual Gateway reset/delete, concurrency, lifecycle cleanup, subprocess cancellation, and unrelated/shared/running-session isolation.
  • Full remote pnpm check:changed: passed, including formatting, documentation, zero-warning lint, core and test typechecks, all three zero-finding unused-export scans, database-first guards, SDK/boundary checks, and runtime cycle checks.
  • Fresh structured gpt-5.6-sol --thinking xhigh autoreview: no accepted or actionable findings.

Thanks to @aniruddhaadak80 for the original report.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Jul 29, 2026
@steipete
steipete merged commit f14e860 into main Jul 29, 2026
125 of 131 checks passed
@steipete
steipete deleted the codex/s29-bash-process-retention-105625 branch July 29, 2026 08:45
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 29, 2026
* origin/main:
  fix(zalo): stop provider startup after gateway shutdown (#115763)
  fix(agents): bound completed background process retention (#115760)
  fix(plugins): bound hook execution and retire stale registrations (#115695)
  fix(ui): collapse custodian startup error gap (#115720)
  fix(gateway): reload edited hook transforms (#107875)
  refactor: centralize channel streaming config hints (#115739)
  fix(msteams): finalize sent replies after dispatch (#82354)
  fix(cron): deliver explicitly configured failure alerts (#115762)
  fix(hooks): resolve inbound claim conversation once (#115491)
  refactor: retire legacy provider and secret paths (#115655)
  fix(memory): reject malformed QMD result entries (#115705)
  fix(diagnostics): keep internal thinking out of telemetry [AI] (#115261)
  fix(ui): localize remaining control surfaces (#115730)
  fix(gateway): prevent model owner mismatch after plugin activation (#115747)
  fix(agents): run reply hooks for restart recovery (#115711)
  fix(cron): initialize detached hook run sessions (#115765)
  fix(ios): keep stop available for staged voice notes (#115744)
  fix(doctor): preserve config includes during cleanup (#115723)
  fix(memory): keep dreaming consolidation within project scope (#115721)
  fix(discord): keep tool rows under verbose progress (#111947)

# Conflicts:
#	ui/src/pages/custodian/custodian-surface.ts
#	ui/src/styles/custodian.css
vincentkoc added a commit that referenced this pull request Jul 29, 2026
…ft-ingestion

* origin/main:
  fix(feishu): reject unsupported initial document content (#115697)
  feat(media): probe duration and dimensions for playback metadata (#115728)
  fix(sandbox): scope runtimes by workspace (#115766)
  fix(ui): guide users through missing or broken AI setup (#115716)
  fix(sessions): return direct-agent replies to their active session (#115756)
  fix(zalo): stop provider startup after gateway shutdown (#115763)
  fix(agents): bound completed background process retention (#115760)
  fix(plugins): bound hook execution and retire stale registrations (#115695)
  fix(ui): collapse custodian startup error gap (#115720)
  fix(gateway): reload edited hook transforms (#107875)
  refactor: centralize channel streaming config hints (#115739)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
…ft-ingestion

* origin/main:
  fix(feishu): reject unsupported initial document content (openclaw#115697)
  feat(media): probe duration and dimensions for playback metadata (openclaw#115728)
  fix(sandbox): scope runtimes by workspace (openclaw#115766)
  fix(ui): guide users through missing or broken AI setup (openclaw#115716)
  fix(sessions): return direct-agent replies to their active session (openclaw#115756)
  fix(zalo): stop provider startup after gateway shutdown (openclaw#115763)
  fix(agents): bound completed background process retention (openclaw#115760)
  fix(plugins): bound hook execution and retire stale registrations (openclaw#115695)
  fix(ui): collapse custodian startup error gap (openclaw#115720)
  fix(gateway): reload edited hook transforms (openclaw#107875)
  refactor: centralize channel streaming config hints (openclaw#115739)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor] Bash Process Registry: Bounded Finished Session Count and Scope-Keyed Lifecycle Cleanup

2 participants