Skip to content

fix(memory): release MCP runtimes after memory flushes - #150899

Merged
steipete merged 2 commits into
mainfrom
codex/fix-private-memory-mcp-retirement-20260917
Sep 17, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/fix-private-memory-mcp-retirement-20260917

Conversation

@steipete

@steipete steipete commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #150874

What Problem This Solves

Optional memory flushes retained their private MCP runtimes after completion or interruption, accumulating runtimes across background runs.

User Impact

Background memory work releases its tool runtime when it finishes. Continuing conversation sessions retain their existing MCP lifetime.

Why This Change Was Made

The existing detached-session factory now prepares the run-end cleanup setting alongside the detached context. The runner consumes it through its existing options spread, and the existing settlement owner preserves active leases and retires the original and accepted successor IDs. The regression checks retirement before fixture cleanup.

Evidence

The controlled baseline replay reproduced three retained private runtimes. The repair passes all 13 factory cases and the three ordered completed/interrupted/requester cases. Full changed checks and independent P2 review pass. The oversized caller remains unchanged from main; no cap or baseline exception is needed. Exact-head CI is pending.

@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 17, 2026
@steipete
steipete marked this pull request as ready for review September 17, 2026 12:44
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 17, 2026, 9:28 AM ET / 13:28 UTC (Revision 2).

ClawSweeper review

What this changes

Private memory-flush runs now request MCP tool-runtime cleanup when they finish, with regression checks for completion and interruption.

Merge readiness

⛔ Blocked before merge - 1 item remains

The fix remains necessary on current main, and no blocking defect was found. The merged related PR addresses fixture teardown only; this protected PR supplies the production repair.

Priority: P2
Reviewed head: 4b8147085e1013109721383f34776b4295f51289

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair reuses the correct lifecycle owner and adds meaningful regression checks, with no blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied Repository State identifies a MEMBER-authored PR, so the external-contributor proof gate does not apply. The reported completed/interrupted boundary tests exercise memory flushing through the real runner and a local HTTP fixture; they are supplemental validation, not a claimed live deployment run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied Repository State identifies a MEMBER-authored PR, so the external-contributor proof gate does not apply. The reported completed/interrupted boundary tests exercise memory flushing through the real runner and a local HTTP fixture; they are supplemental validation, not a claimed live deployment run.
Evidence reviewed 7 items Current main still lacks the repair: The detached-session factory omits cleanupBundleMcpOnRunEnd, and the memory runner spreads that factory result without independently enabling cleanup.
Latest release check: The same factory in the supplied latest release, v2026.9.4, also omits run-end cleanup; release inspection does not establish an already-shipped fix.
Existing cleanup owner preserves scope: The runner consumes the factory result at agent-runner-memory.ts:1733. Its finally-path settlement retires original and accepted successor session IDs with preserveActiveLeases enabled; the manager waits for active leases before disposal. This reuses OpenClaw's existing lifecycle contract without changing authorization or persistence.
Findings None None.
Security None None.

How this fits together

Memory flushing runs a private agent turn over a detached conversation snapshot to preserve useful notes. Its MCP tool runtimes belong to that temporary run, while the foreground conversation continues independently.

flowchart TD
  A[Conversation snapshot] --> B[Private memory flush]
  B --> C[Agent run and tool runtime]
  C --> D[Completion or interruption]
  D --> E[Run settlement]
  E --> F{Active leases remain?}
  F -->|Yes| G[Defer retirement]
  F -->|No| H[Dispose private runtime]
  G --> H
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +6, Tests +56. Total +62 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 7 1 +6
Tests 1 87 31 +56
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 94 32 +62

Review metrics

None.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/auto-reply/reply/memory-flush-session.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep private memory runs on the existing lease-aware retirement path while preserving continuing conversation runtimes.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the path: private memory runs omit the cleanup option that settlement requires to retire their runtimes. The PR reports a failing baseline replay; this review did not execute it.

Is this the best way to solve the issue?

Yes, enabling the existing cleanup contract at the detached-session factory is a narrow repair, and the caller already carries that setting into execution.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against aac3b2773c7f.

Labels

Label justifications:

  • P2: This is a focused resource-lifetime repair for accumulating background memory runtimes, with no demonstrated urgent outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied Repository State identifies a MEMBER-authored PR, so the external-contributor proof gate does not apply. The reported completed/interrupted boundary tests exercise memory flushing through the real runner and a local HTTP fixture; they are supplemental validation, not a claimed live deployment run.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-17T12:52:22.557Z sha e0dbab8 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 4258806 into main Sep 17, 2026
212 checks passed
@steipete
steipete deleted the codex/fix-private-memory-mcp-retirement-20260917 branch September 17, 2026 13:46
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 18, 2026
* fix(memory): retire MCP runtimes after private memory flushes

* refactor(memory): prepare cleanup with detached run context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant