Skip to content

fix(plugins): keep admitted turns running during opted-in reloads - #184243

Merged
steipete merged 13 commits into
mainfrom
steipete/fix-plugin-generation-retirement-20261026
Oct 30, 2026
Merged

steipete merged 13 commits into
mainfrom
steipete/fix-plugin-generation-retirement-20261026

Conversation

@steipete

@steipete steipete commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Plugin reloads can wait 60 seconds for admitted parent and native-subagent turns, then return UNAVAILABLE while new work waits behind the drain (#183995). Those turns still need their original tools and end hooks after preparation, so releasing their generation leases early is unsafe.

This change lets explicitly audited plugins declare generationOverlap: true. A prepared successor becomes available to new work while admitted turns keep their predecessor's callable authority until they finish.

User Impact

Overlap remains default-off, and both affected generations must opt in. Channels and exclusive host resources stay serialized. This PR opts in only these two bundled plugins:

Plugin / surface Audit result
Memory Core Opt in. Managers and database handles are instance-scoped; existing writer/index coordination spans module generations. The newest live maintenance owner schedules work, and rollback restores its predecessor.
LLM Task Opt in. Request-local factories and execution, without shared mutable runtime or exclusive services.
Knowledge No overlap opt-in; existing reload.turnHandover behavior remains separate.
Voice Call Serialized: process-global runtime and exclusive listener.
Channels and other plugins No overlap enabled by this change.

Old turns retain their original tools, providers, hooks, and end hooks. New admissions select the published successor. Credentials, approvals, cancellation, caller/source authority, and external-effect checks remain live.

Why This Change Was Made

Generation admission and host retirement remain the owners. The host prepares the successor before publication, publishes it for new work, and retains the predecessor until its last finite holder releases. Only then does retirement stop captured services and revoke/dispose the old authority and resources. Preparation failure leaves the predecessor active; rapid toggles retire intermediate generations independently; shutdown uses the same retirement owner. runtimeRetention exposes outstanding holders. The retirement prerequisite was not behavior-neutral alone, so it is included here.

The manifest is the capability surface; there is no parallel generation manager. If a plugin declares both overlap and turn handover, overlap takes precedence, including when another affected plugin forces serialized replacement. Detached continuations leave the completed producer's scope before fresh admission while preserving Gateway identity, cancellation, target, placement, and commit checks.

Default-off leases construct no callable consumers. Opted-in instance selection happens once per immutable generation, scopes share their consumer/binding map, and disposal reuses existing settlement waiters. Duplicate lease construction, per-consumer completion promises, and recovery/occurrence machinery now owned by main have been removed. Knowledge's manifest matches main exactly.

Production runtime/manifests grow by 756 lines (three lines are formatting of the nested retry guard after this rebase); retained authority, deferred service/resource retirement, diagnostics, and complete caller migration require that growth. The broader requested exclusion filter is +1,112, including 337 benchmark lines and fixture/config entries. The exact 1,943-line test allocation covers overlap, serialized defaults, rollback, retirement, restart, authority, and caller migration; the extra nine lines ensure failed provider entry reaches fixture cleanup. No benchmark lint suppressions or shared perf README sections were added.

Evidence

Integration base: 2f504abebddca671613ede82dee5a704fd4d9478. Final head: 9557ae6f45abf2fdb7af3f62c5202b08a93e01d5.

Exact-head CI attribution and repair (October 30)

The failed run at 5bd7ebc0689784f783ea85268f8a469cd69fc181 was investigated from the saved logs without downloading them again. Each reported Node/UI failure was replayed twice on that PR head and twice on pinned main, using nice -n 10, --maxWorkers=8, uptime capture, the repository test wrapper, and the native UI-E2E config. The adjacent cron user-pin and legacy-pin controls were included.

Failed job / case Main 2f504abe PR 5bd7ebc0 Classification / action
Baseline ratchets / test-lines Guard passes; 32 lines slack CI merged tree exposed 2,757 inherited lines of debt Inherited shared census; take #188620 by rebase, retain existing 1,943-line allocation
Runtime request facts / reload-baseline Fails 2/2, status error instead of ok Same failure 2/2 Inherited; unchanged
Reply fallback transcript, Responses and Completions Both fail 2/2, undefined reply Same failures 2/2 Inherited; unchanged
Cron explicit fallback / own-model policy; timeout fallback transcript All three fail 2/2; no fallback request, silent result Same failures 2/2 Inherited; unchanged; user-pin and legacy-pin controls pass on both revisions
Terminal delivery / strict NO_REPLY test Fails 2/2, empty result status ok instead of error Same failure 2/2 Inherited; unchanged
Browser correction to system direct command Fails 2/2, steered instead of followup Same failure 2/2 Inherited; unchanged
xAI rejection priority / statusless fallback Times out at 180 s, 2/2 Same timeout 2/2 Inherited; unchanged
Sidebar quiet leading ring Passes 2/2 Passes 2/2 Flaky; no assertion or polling change
Phone boot composer draft/frame Fails 2/2; four-pixel vertical shift Same failure 2/2 Inherited; unchanged
Android native access / 16K image Native paths unchanged by PR Gradle classpath dependency resolution fails before tests Infrastructure; no native change
Shared OpenClawKit dead-code intersection Workflow unchanged by PR Missing/invalid Periphery producer execution CI provenance/metadata failure before report download; no native change

The test-line failure exposed 2,757 lines of inherited debt: CI's merged tree had 6,309,440 lines against a 6,306,683 ceiling, while the PR itself added exactly 1,943 lines and already carried exactly 1,943 lines of allocation. Main #188620 repairs the stale shared census from #188561. The rebased guard passes: 6,309,968 test lines; 6,310,000 ceiling; 32 lines slack. No allocation increase, weakened assertion, timeout increase, or lint suppression was added.

Native classification is limited to the observed failures: Android failed Gradle classpath dependency resolution before native tests; Periphery rejected missing/invalid producer-execution metadata before report download/intersection. This PR changes neither native code nor those workflows. Native infrastructure was left unchanged.

All 55 PR-focused test files pass on the rebased head, including all 48 touched tests, lifecycle consumers, closure guards, and prompt/tool prefix stability (459.9 seconds through the native wrapper). pnpm tsgo:core, pnpm tsgo:test:root, pnpm tsgo:extensions:test, and the explicit plugin-test typecheck leaf pass. The separately attributed failures above remain failures; this focused result does not claim they were fixed. Oxlint, oxfmt, and git diff --check pass.

Fresh Codex autoreview is scoped-clean through P2, with no accepted findings in either pass. The rebase was conflict-free and all 13 prior patches replayed unchanged. Default-off and both audited opt-ins are unchanged. One push publishes the repaired integration. No CI rerun, Team access, or merge. New exact-head CI run is queued. The PR is open, ready, and mergeable.

Prior overlap and owner measurements

These measurements compare base f9135d23491031bbc55bd265f5be07c246b6139b with candidate b9a5f048a720b7273f94746108e3b1b6b3c2bdb5; they have not been rerun after this main integration.

Five selected regressions failed with behavior assertions on that measurement base and passed on that candidate:

Boundary Base failure
Reload during an admitted call draining instead of successor publication
Combined overlap/turn-handover declarations Unwanted handover request
Memory Core writers across module generations Successor writer enters before predecessor release
Maintenance ordering Stale reconciliation overwrites the successor schedule
Preparation rollback Predecessor maintenance is not restored

Prior isolated Gateway proof: config patch 742 ms, fresh successor work completed 1,392 ms after the patch request, and tools.effective 15 ms. Parent/native-child provider holds lasted 100,000 / 100,515 ms. Their old tools, before_prompt_build, and agent_end used the original registration; four real Memory Core reads succeeded. Both predecessors disappeared after final release (first retirement poll: 3 ms), old service stop/dispose ran exactly once, reload status cleared, and graceful shutdown exited 0 with no closed-scope warnings. These are functional observations, not latency percentiles.

Lease workload CPU µs/lease, base → candidate Sampled allocation KiB/lease, base → candidate
Default-off 63.35 → 58.35 (−5.00 µs; −7.9%) 116.89 → 115.18 (−1.71 KiB; −1.5%)
All opted-in 60.57 → 78.20 (+17.63 µs; +29.1%) 117.09 → 161.19 (+44.11 KiB; +37.7%)

Percentages above compare arm means. Default-off CPU pairs have mixed signs, and the first pair dominates the favorable mean: this is not a stable CPU win. Default-off allocation is small/mixed, without a consistent adverse pattern. The all-opted-in cost is consistent across all five pairs (CPU +22.6–34.6%; allocation +36.0–39.5%). This is the explicit cost of retaining callable authority for all 40 synthetic plugins; only two bundled plugins opt in.

Mean sampled host load (one-minute load average, before/after each arm): default-off timing 54.27 / 53.68, allocation 48.20 / 48.65; opted-in timing 52.85 / 51.53, allocation 51.20 / 51.06, base/candidate respectively. All 44 subprocesses completed successfully and runtime artifact hashes were unchanged.

Default-off leases retain the original 40 work references and add no consumer tracking. Opted-in leases add 40 work and 40 consumer references; releasing the lease restores its pre-lease baseline (40 registration call references remain). Tool identity is preserved.

The owner protocol uses 40 synthetic plugins, 16 calls per lease, 200 warmup leases, and five counterbalanced pairs × 4,000 leases per arm and instrumentation mode. CPU and sampled allocation run separately. Default-off and all-opted-in workloads are reported separately; the latter deliberately exercises 40 retained plugin consumers. Artifact and tool identities, return to pre-lease retention after release, and host load are recorded for each arm. Historical whole-Gateway stress and identical-source controls were inconclusive; no fresh whole-Gateway non-adverse claim is made here.

@clawsweeper

clawsweeper Bot commented Oct 26, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T20:54:59.337353Z 9557ae6 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: llm-task Extension: llm-task extensions: memory-core Extension: memory-core cli CLI command changes agents Agent runtime and tooling plugin: file-transfer size: XL labels Oct 26, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR lets explicitly opted-in plugin generations overlap while admitted turns finish using their original generation.

Example: Change Memory Core configuration during 100-second parent and native-subagent turns.

  • Before: The supplied baseline reproduction returned UNAVAILABLE after about 60 seconds.
  • After: The candidate applied the change in 573 ms while the original turns completed on their retained generation.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong functional evidence and no new concrete patch defect; required upgrade coverage remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Plugin configuration changes can exhaust the drain budget while long-running parent or subagent turns retain the previous generation.
Reason: The maintainer-authored direction provides useful reload continuity through an explicit author contract, with serialized defaults and exclusive-resource handling preserved.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open and unmerged: the overlap capability has clear value, no new concrete defect was found, and Peter’s explicit SDK/manifest hold remains active.

Priority: P2
Reviewed head: 2f30996c1c7836f4a4993eab1eb8b642f90c9dd2

Before merge

  • Await maintainer action - Peter must acknowledge the SDK/manifest contract and lift the explicit merge hold.

Findings

None.

Tests

  • Missing end-to-end proof: Provide a v2026.10.7-to-candidate upgrade replay followed by overlap, preserving existing plugin settings and memory data, with sensitive values redacted.
Agent review details

How this fits together

Gateway plugin reload prepares and publishes registries consumed by agent admissions, tools, providers, hooks, and services; the existing retirement owner releases predecessor resources after admitted work settles.

flowchart TD
  A[Plugin reload request] --> B[Prepare successor]
  B --> C[Publish successor]
  C --> D[New turn admissions]
  C --> E[Retained predecessor turns]
  E --> F[Existing retirement owner]
  F --> G[Stop services and dispose resources]
Loading

Technical review

Best possible solution:

Publish successors through the existing retirement owner while old turns retain exact scoped callables and current effect checks.

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

Current main’s pre-registration drain explains the supplied 100-second-turn timeout reproduction; no target code was executed during this review.

Is this the best way to solve the issue?

Extending the existing retirement and prepared-runtime owners is coherent, and both-generation opt-in preserves the documented serialization boundary for other plugins.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Serialized plugin replacement changes intended behavior with a stated reason (feat: manage and reload plugins without Gateway restarts #145484: Use one Gateway-owned prepare, drain, publish, and retire lifecycle so replacement safely releases predecessor resources.)
  • Exact admitted plugin lifetime keeps the original intent (05a2844: Keep the supplying plugin instance alive through accepted execution and cleanup.)
  • Dreaming background maintenance keeps the original intent (88dbe36: Historical dreaming cleanup is instance-owned maintenance rather than a start-hook prerequisite; service stop still joins it.)
  • Retention diagnostics keeps the original intent (bd2dbfd: Expose bounded, payload-free retained-reference facts only to administrators.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main retains serialized replacement: Fetched main still drains retained work and stops predecessor resources before successor registration; the central overlap capability remains absent. The diagnostics-only precursor explicitly preserves the timeout: fix(plugins): show acquisition owners in reload timeout logs #183995. (src/gateway/server-plugin-reload.ts, 99f7a303e3ff)
  • Default-off lease correction: The immutable generation selects opted-in instances once; ordinary generations receive the shared direct runner and finite generation retention without callable consumer scopes. The mixed-generation regression also checks that ordinary calls reject after quiescence while opted-in calls remain usable. (src/agents/prepared-model-runtime.plugin-lifetime.ts:253, 2f30996c1c78)
  • Existing retirement owner and eligibility boundary: Superseded instances finish finite admitted work before captured service cleanup and revocation. Eligibility requires both loaded generations to opt in and excludes channels and identified exclusive host resources. (src/gateway/server-plugin-reload-cleanup.ts:419, 2f30996c1c78)
  • Earlier concerns addressed: Inspection uses the expanded protocol schema and filters predecessors by Gateway owner. Standing-intent rollback invokes the restored owner’s reconciliation callback; its regression creates pending expirations before rollback. (extensions/memory-core/src/standing-intents.ts:149, 2f30996c1c78)
  • Behavior and measurement evidence: The REST body, captured with source-body SHA256 9f5c693526fa7b6798c89aab21108c1e4fbfcb1bc3cf0eb2b59f4d3718027a64, records the isolated Gateway overlap result and cancellation suppressing a pending file write. Separate five-sample owner measurements report neutral default-off cost and opted-in CPU/allocation increases of 27.54%/45.94%; they do not establish whole-Gateway performance neutrality. Both downloaded screenshots were inspected and show historical plugin-management UI rather than this overlap scenario. (2f30996c1c78)
  • Production proof remains applicable: The final commit changes only the worker context-engine test and has bd99115 as its parent, independently supporting reuse of that build’s production-path evidence. (src/gateway/worker-environments/worker-turn-context-engine.test.ts:252, 2f30996c1c78)

Likely related people:

  • Josh Lehman: Raw commit bd2dbfd adds packages/gateway-protocol/src/schema/plugin-retention.ts:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bd2dbfdeb493; files: packages/gateway-protocol/src/schema/plugin-retention.ts)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Manifest contract 1 optional boolean; 2 bundled opt-ins generationOverlap defaults to serialized replacement; Memory Core and LLM Task explicitly enable the new lifetime contract.

Labels

Label changes:

  • add status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.

Label justifications:

  • P2: Avoids reload timeouts during long admitted turns on a limited, explicitly opted-in surface.
  • merge-risk: 🚨 compatibility: Extends the public manifest and documented plugin lifetime contract while preserving serialized defaults.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-26T05:36:16.179Z sha 9c180a9 :: needs real behavior proof before merge. :: [P2] Update the inspection response schema for predecessor diagnostics | [P2] Migrate the remaining prepared-runtime lease fixtures | [P2] Filter predecessor diagnostics by the requesting Gateway owner
  • reviewed 2026-10-26T14:12:57.282Z sha 8f585ef :: blocked before merge. :: none
  • reviewed 2026-10-26T14:21:25.110Z sha 8f585ef :: blocked before merge. :: none

Reviewed October 26, 2026, 1:44 PM ET / 17:44 UTC (Revision 4).

@steipete
steipete force-pushed the steipete/fix-plugin-generation-retirement-20261026 branch from 9c180a9 to 7932953 Compare October 26, 2026 06:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7932953d75

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +160 to 165
maintenance.owners.delete(schedule);
if (maintenance.schedule === schedule) {
maintenance.schedule = [...maintenance.owners].at(-1);
}
for (const job of jobs.values()) {
job.cancel();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Re-arm standing-intent maintenance when restoring a predecessor

If an overlapping candidate is rolled back, restoring maintenance.schedule does not transfer its pending deadlines or trigger a predecessor sweep. For example, after an empty predecessor has exhausted its startup job, creating an intent while the candidate services are preparing schedules expiration only on the candidate; stopping that candidate cancels the job and leaves the restored predecessor with no timer. Expiration and cooldown maintenance then stop until another standing-intent operation happens. Schedule an immediate reconciliation on the restored owner (or transfer its deadlines). The new overlap test misses this because it creates the intent after stopping the retiring owner, which itself re-arms maintenance.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in the current head. Restoring the predecessor now invokes its own target reconciliation callback, rather than only restoring the schedule function. The new regression starts with an idle predecessor, creates intents for two predecessor-owned targets while the candidate is active, rolls back the candidate, and verifies both expiry deadlines are re-armed and processed without another intent operation. This regression failed before the correction and passed afterward; the focused standing-intent file passed all 22 cases.

@steipete
steipete force-pushed the steipete/fix-plugin-generation-retirement-20261026 branch 3 times, most recently from 1907353 to cc874bc Compare October 26, 2026 09:34
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 26, 2026
@steipete
steipete force-pushed the steipete/fix-plugin-generation-retirement-20261026 branch from 34a8390 to 8f585ef Compare October 26, 2026 11:50
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The rollback finding is addressed. The current head has fresh 100-second parent/native-subagent overlap proof with Memory Core, completed A/B stress and four A/A controls, and exact-base/candidate focused attribution replays documented in the body. Independent subagent review (autoreview route unavailable) has no accepted findings remaining. CI is not green: the deletion failure reproduces on base, while two QA setup timeouts remain unattributed. Please keep this PR unmerged pending the SDK/manifest design acknowledgment.

emeric-dandelion-cult pushed a commit to karmaterminal/openclaw that referenced this pull request Nov 7, 2026
… generation

Continuation's own detached re-entries already drop the arming request's
scope and operator grant, but they kept the arming turn's plugin generation:
its registry selection, metadata snapshot, generation registry, prepared
generation pin and plugin invocation scope. A delayed continuation armed before
a plugin reload then ran on the predecessor generation (jump-12 finding F-1).
For an opted-in plugin it reached the closed predecessor scope; for an
ordinary one the stale pins outlived the retired generation.

Wrap all three re-entries in upstream's runOutsideAdmittedGenerationScopes
(openclaw#184243), the helper every upstream detached path uses, with the work
admission outside and the generation drop inside, as in queue/drain.ts:

- dispatchPendingContinuationWorkFromDetachedCallback (work wake, idle-retry
  recovery and hedge re-arms);
- the delegate-dispatch hedge timer;
- the terminal-notice live retry.

The Gateway resolver, the dropped request scope and operator grant, the fresh
detached work scope and the bounded retries are unchanged.

Refs karmaterminal/openclaw-bootstrap#1727

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 0b64649)
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]>
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui cli CLI command changes docs Improvements or additions to documentation extensions: llm-task Extension: llm-task extensions: memory-core Extension: memory-core gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant