Repository navigation
fix(plugins): finish retained cleanup after caller release - #191126
Merged
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
vincentkoc
marked this pull request as ready for review
November 2, 2026 13:27
Member
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 3, 2026
obviyus
added a commit
that referenced
this pull request
Nov 10, 2026
…closed plugin scope (#196700) fix(gateway): run the automatic activity recap outside the finished run's plugin scope When a Codex run ended, the automatic Activity recap never sent its request and the recap stayed at "updating". The Codex runtime emits the run-end event inside the run's plugin invocation scope, and the recap service scheduled the recap from that event without leaving the scope (since #169622). Since #184243, new prepared-model scopes take the caller's scope as their parent, so when the recap checked utility model auth after the run had finished, it hit "Plugin invocation scope is closed", and its own error handling hit the same closed scope. The run-end recap is now scheduled inside pluginInvocationContext.exit(...), the same pattern #191126 used for #191123. The RPC and archive recap paths are unchanged. Evidence: a built Gateway in Docker with the real Codex app-server and a stand-in endpoint. On main, two Codex runs sent no automatic recap request and stayed at "updating"; with debug logging the Gateway logged "Activity recap background work failed {"error":"Plugin invocation scope is closed"}". With this change two Codex runs each sent one recap request and the summary became current. The RPC-requested recap works on both, plain OpenAI runs recap on both, and plugin-invocation-scope.test.ts passes on both, so genuinely closed scopes still throw. Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus
added a commit
that referenced
this pull request
Nov 10, 2026
…with "Plugin invocation scope is closed" (#196750) fix(reply): deliver session-targeted cron and system-event replies outside a closed plugin scope Replies of cron jobs targeted at a conversation (sessionTarget "session:<key>") and replies to system-event wakes were never delivered. Delivery ran inside the triggering run's plugin invocation scope, which had already closed, so the channel send failed with "Plugin invocation scope is closed" and the run recorded a delivery error. Session-event delivery now runs outside that scope with pluginInvocationContext.exit, the same pattern as #196700 and #191126. Evidence: a built Gateway on node 24.22.1 in secretless Docker with a scripted local model and a stand-in Telegram Bot API recording every sendMessage, two runs each. On main a session-targeted cron run (openclaw cron run) and an openclaw system event --mode now wake delivered nothing, and the run recorded "Failed to route reply to telegram: Plugin invocation scope is closed". With this change both replies are delivered once. A normal chat turn and an isolated announce cron job deliver on both, and plugin-invocation-scope tests pass on both, so closed scopes still throw. Details: #196750 (comment). Closes #196749. Thanks @masatohoshino. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 11, 2026
…closed plugin scope (openclaw#196700) fix(gateway): run the automatic activity recap outside the finished run's plugin scope When a Codex run ended, the automatic Activity recap never sent its request and the recap stayed at "updating". The Codex runtime emits the run-end event inside the run's plugin invocation scope, and the recap service scheduled the recap from that event without leaving the scope (since openclaw#169622). Since openclaw#184243, new prepared-model scopes take the caller's scope as their parent, so when the recap checked utility model auth after the run had finished, it hit "Plugin invocation scope is closed", and its own error handling hit the same closed scope. The run-end recap is now scheduled inside pluginInvocationContext.exit(...), the same pattern openclaw#191126 used for openclaw#191123. The RPC and archive recap paths are unchanged. Evidence: a built Gateway in Docker with the real Codex app-server and a stand-in endpoint. On main, two Codex runs sent no automatic recap request and stayed at "updating"; with debug logging the Gateway logged "Activity recap background work failed {"error":"Plugin invocation scope is closed"}". With this change two Codex runs each sent one recap request and the summary became current. The RPC-requested recap works on both, plain OpenAI runs recap on both, and plugin-invocation-scope.test.ts passes on both, so genuinely closed scopes still throw. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 11, 2026
…with "Plugin invocation scope is closed" (openclaw#196750) fix(reply): deliver session-targeted cron and system-event replies outside a closed plugin scope Replies of cron jobs targeted at a conversation (sessionTarget "session:<key>") and replies to system-event wakes were never delivered. Delivery ran inside the triggering run's plugin invocation scope, which had already closed, so the channel send failed with "Plugin invocation scope is closed" and the run recorded a delivery error. Session-event delivery now runs outside that scope with pluginInvocationContext.exit, the same pattern as openclaw#196700 and openclaw#191126. Evidence: a built Gateway on node 24.22.1 in secretless Docker with a scripted local model and a stand-in Telegram Bot API recording every sendMessage, two runs each. On main a session-targeted cron run (openclaw cron run) and an openclaw system event --mode now wake delivered nothing, and the run recorded "Failed to route reply to telegram: Plugin invocation scope is closed". With this change both replies are delivered once. A normal chat turn and an isolated announce cron job deliver on both, and plugin-invocation-scope tests pass on both, so closed scopes still throw. Details: openclaw#196750 (comment). Closes openclaw#196749. Thanks @masatohoshino. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to clawhaven/openclaw
that referenced
this pull request
Nov 23, 2026
…nclaw#191126) (cherry picked from commit 5a160d1) Release adaptation: Cleanup exits finished invocation context while retaining active cleanup lease; later recap and event dispatch changes are different consumers. Co-authored-by: RomneyDa <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #191123
What Problem This Solves
Fixes retained plugin cleanup being rejected with
Plugin invocation scope is closedwhen teardown starts inside a caller that has already finished. This can surface as a best-effort context-engine completion warning.User Impact
Host-owned cleanup can finish after its original caller closes. Ordinary callbacks captured by that caller remain revoked, as do closed consumer callbacks and calls to unrelated retiring plugins. No provider, account, configuration, schema, or public API changes.
The live warning did not identify its exact phase. This repair does not establish that the warning caused missing replies, offline periods, or a failed
onSubagentEndedhook.Why This Change Was Made
consumer.close()owns the transition from operation callbacks to a separate teardown token. It revoked callbacks correctly, but entered teardown while retaining the ambient caller scope; the closed caller rejected entry before cleanup could install its own bindings. Exit that inherited invocation scope at the existing consumer owner, matching physical plugin/module disposal. Registry provenance, failure collection, and final release ordering stay with the same owner.This completes the lifetime distinction already used in #163818 and preserves the ordinary callback guard involved in #158369. It adds no second cleanup path or retry.
Evidence
2ac8f5ac1e989fb12072d1ce27c5d9cc762e399c. Signed commit, normal content/format hooks, targeted formatting, whitespace/privacy checks, and staged test-line ratchet passed. Production file remains within its line cap.scoped-cleanthrough P2, no actionable findings. Reviewed source bytes match the commit.plugin-instance.test.ts35 andplugin-invocation-scope.test.ts7 in job125303920703, plus context-engine cleanup 10 in job125303920771. Both new closed-caller regressions passed. The enclosing plugin group passed 830 tests across 50 files; both selected wrappers exited 0.Focused proof command: