Skip to content

refactor: keep plugin work and cleanup owned during retirement - #144252

Merged
steipete merged 8 commits into
mainfrom
codex/plugin-foundation-verify-20260910
Sep 11, 2026
Merged

steipete merged 8 commits into
mainfrom
codex/plugin-foundation-verify-20260910

Conversation

@steipete

@steipete steipete commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Related: #135599, #141280. The Control UI drain fix merged separately in #145118 (b78d472e).

What Problem This Solves

Plugin preparation and registry replacement could dispose dependencies still used by requests, model helpers, or another Gateway. This foundation lets accepted work keep its supplying plugin instance through completion and cleanup, providing the prerequisite for restart-free plugin management.

Why This Change Was Made

One managed instance owns its registered callbacks, runtime-store slots, captured source, and disposal. Registries and metadata caches retain their own dependencies; retirement stops new ordinary calls, while admitted consumers and surviving Gateways keep their exact owners. Idle cached publications release their holds when those owners retire. The separate CLI registry, setup-loader state, and runtime-boundary implementation are removed.

The design preserves synchronous registration and startup loading, including TypeScript/Jiti behavior and Bun's native loader semantics. It also carries the related CI repairs: runtime-dependent startup and package tests declare the canonical build prerequisite; SDK readiness covers the resolved relative imports used by compiled bundled plugins; and the now-merged Control UI prerequisite observes Gateway drain before sidecar teardown. The subsequent management cut supplies enable, disable, install, uninstall, and explicit reload orchestration. No operator option, SQLite schema/migration, or protocol-version change is introduced.

User Impact

Requests and setup flows keep their plugin dependencies until their work and cleanup finish. Plugin authors can use api.lifecycle.onDispose and api.lifecycle.signal; the existing lifecycle contract remains supported. Cleanup is best effort, with visible failures and bounded disposer waits. Plugins remain responsible for unmanaged timers, listeners, sockets, watchers, and child processes; native objects and engine caches are not universally reclaimed. Fresh captured-source reload requires Node's synchronous module hooks, while Bun retains its native/Jiti startup behavior. See plugin lifecycle and cleanup.

Evidence

  • Earlier Linux built-Gateway startup/RPC/shutdown proof passed on tree 005e642e, including a throwing cleanup callback and natural exit of both Gateways. Later source-bound regressions cover shared-Gateway retention, memory acquisition, captured-source loading and Bun startup. These historical results retain their original identities.

  • All three final native compatibility flows passed on tree 840b890d: configured TypeScript upgrade from preserved official 2026.9.2 state, fresh TypeScript startup, and a JavaScript/CJS/asset plugin installed by the actual stable CLI. Each returned two ordered plugin RPCs and healthy status, started/stopped once, and exited naturally within the unchanged ten-second grace. Config, plugin bytes, managed install records and stable snapshots remained unchanged; all processes/groups ended and ports closed. Both drivers verified source and all 23,717 built artifacts before/after. Prior failures and the separate diagnostic replay remain preserved. This completes the fresh-start/stable-upgrade replay requested in ClawSweeper revision 8, reviewed on c63.

  • The published 2026.9.3 upgrade-survivor replay passed in 235 seconds on the actual failing CI merge e5024e2f plus the sealed SDK readiness fix, tree 6b31ee12. Its candidate Gateway canary exited 0 in 12.817 seconds; the earlier run failed after 63.437 seconds with the Node ESM linking race. Migration, cron, agent, installed-plugin, repeat-update and doctor continuation checks passed. This is causal SDK proof on that source, not a run of the rebased PR head; all owned leases were closed.

  • Focused corrections passed 602 package/planner tests and 51 SDK owner/sibling tests with the SDK changed-file gate. The Control UI fix passed 35 tests and real 80 MiB filesystem integration, including cancelled staging cleanup and a successful fresh generation. The exact eight-file correction on 840b890d completed a scoped-clean P2 review. Runtime JavaScript, SDK/plugin companions, UI and metadata rebuilt in 157.6 seconds using the existing skip-declarations profile; earlier declarations were preserved.

  • The real rebase onto 7adce1e1 replayed all seven commits. The four resolved files match the reviewed main/F combinations, including main's install authority checks, full media preflight table and per-handler prompt capability. All 17 checked SDK/UI/native-compatibility owner files remain byte-identical to the proven 840b890d source; dependency manifests are unchanged. On rebased parent eebf9fd3, 161 tests across nine installer/media/hook/memory files passed in 94.81 seconds. The selected changed-file gate passed, including core production/test types, all three dead-export scans, typed lint, formatting, and repository guards.

  • CI on parent eebf9fd3, testing merge c21a7698, finished with 125 successful jobs and 11 skipped. The upgrade Docker lane, Windows lanes and real-Gateway UI E2E passed. Two native PR-harness cases failed because main's new contributor-credit check requested an endpoint missing from the shared fake GitHub client. The six-line fixture-only correction derives authors from the synthetic Git repository and preserves credit verification. Both original cases reproduced red then passed on that exact CI source; all 16 selected tooling checks and independent P2 review passed. Production code is unchanged by this final correction.

  • The latest rebase preserves main's asynchronous transcript snapshots and revision checks at the write boundary alongside per-entry plugin cleanup. Its single conflict was resolved without discarding either owner contract. On 518125d1, all 127 tests across six transcript files, production types, targeted typed lint, formatting and diff checks passed. All 17 previously checked loader/startup compatibility owners remain byte-identical to the live-tested source; dependency fields and lockfiles are unchanged.

  • Full CI on 518125d1 passed: 128 successful jobs, 11 skipped, and the required gate green. The final main refresh resolves only the independently updated native PR fixture; all 264 foundation production paths and the tested PR workflow/fixture are byte-identical to that green source. Current-head CI subsequently passed as recorded below.

  • Downstream integration on combined tree 18b3d63c also passed fresh normal builds and the agent-management/TypeScript reload flow, embedded/native continuity, and install/update/uninstall flows. Those runs include the later management cuts; model responses were synthetic, while the Gateway, agents, tools, installer and pinned native Codex executable were real. All owned processes, ports and Testboxes closed.

Current head: ddfd8e413e177f1c8552de9c4e9a097ba1f760d6, tree a7b3f8a92818530f550aad6ffffd45ae747a0551, base 97e6e3cd4e400529ff729119f5aa030e33196037. Current-head CI passed with 128 successful jobs, 11 skipped, and the required gate green. The final conflict resolution preserves the tested production and fixture code; historical/isolated proof retains its original source identities.

Against this main base, the foundation cut adds 5,106 production lines, 15,106 test/support lines, 432 tooling lines and 175 documentation lines; config/baselines decrease by 11 and the lockfile grows by three. Growth implements instance admission, captured-source ownership and retained cleanup. The later management cut is counted separately. No new operator configuration, schema, persisted format or protocol version is introduced.

Retained follow-ups: attribute the filtered lifecycle-test failure whose original-order file passed; document the internal previousRegistry precondition for explicit host overrides; clarify shipped CWD-relative CLI resolvePath; and remove the source-only channel helper's obsolete external-dist retry path.

@steipete steipete self-assigned this Sep 10, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord gateway Gateway runtime extensions: memory-core Extension: memory-core cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling plugin: file-transfer plugin: beam Beam session sharing plugin size: XL maintainer Maintainer-authored PR labels Sep 10, 2026
@steipete
steipete force-pushed the codex/plugin-foundation-verify-20260910 branch 3 times, most recently from 35e43a7 to 383d65c Compare September 10, 2026 18:35
@steipete
steipete marked this pull request as ready for review September 10, 2026 18:35
@steipete
steipete requested review from a team as code owners September 10, 2026 18:35
@clawsweeper

clawsweeper Bot commented Sep 10, 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.

@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Sep 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • package.json
  • pnpm-lock.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfiles or workspace dependency policy changes are present.
  • Treat pnpm-lock.yaml and package-lock.json diffs as dependency security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Dependency graph changes noted

This PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin, a member of @openclaw/openclaw-secops, or an OpenClaw organization member with Maintain or Admin repository access.

  • Current SHA: ddfd8e413e177f1c8552de9c4e9a097ba1f760d6
  • Trusted actor: @steipete
  • Trusted role: pull request author; openclaw-secops

Security review is still recommended before merge when the dependency graph change is intentional.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 11, 2026, 4:25 PM ET / 20:25 UTC (Revision 13).

ClawSweeper review

What this changes

The branch keeps plugin code, callbacks, active work, and cleanup attached to their owning instance during retirement, with corresponding SDK, consumer, and build changes.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains a useful, maintainer-owned foundation that current main does not implement. All 566 introduced paths match the previous reviewed head byte-for-byte; the earlier donor-release repair remains present, and this review found no additional actionable defect.

Priority: P2
Reviewed head: ddfd8e413e177f1c8552de9c4e9a097ba1f760d6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong recorded runtime evidence supports a coherent ownership refactor with no actionable findings and a documented external-loader compatibility limitation.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Recorded built-Gateway RPC/shutdown and fresh/stable-upgrade runs exercise the changed loader and lifetime owners, with successful requests, preserved state, and natural cleanup; historical final-dispatch evidence also covers retained, unpublished, replaced, and revoked callbacks. Source continuity preserves the prior assessment, while blocked log retrieval remains a reviewer limitation rather than missing contributor proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded built-Gateway RPC/shutdown and fresh/stable-upgrade runs exercise the changed loader and lifetime owners, with successful requests, preserved state, and natural cleanup; historical final-dispatch evidence also covers retained, unpublished, replaced, and revoked callbacks. Source continuity preserves the prior assessment, while blocked log retrieval remains a reviewer limitation rather than missing contributor proof.
Evidence reviewed 11 items Review continuity verified independently: The complete GitHub tree for previous reviewed head 518125d was compared with local HEAD using blob identities. All 566 merge-base..HEAD paths matched, including absence for deleted paths. The API tree was not truncated. This establishes content continuity, not a claim that hashes substitute for source review.
Foundation remains absent from main and latest release: Both fetched main and v2026.9.4 lack plugin-instance.ts and retain the older registry-epoch implementation. The supplied merged prerequisites address narrower shutdown problems; none establishes completion of this foundation.
Instance admission and cleanup ownership: The instance owner distinguishes ordinary calls, retained consumers, and host cleanup. Retirement closes admission, invalidates ordinary tokens, waits for consumers, and reports bounded disposer failures. Registry authority reads current record ownership rather than trusting an identifier alone.
Findings None None.
Security None None.

How this fits together

OpenClaw loads plugins into registries used by Gateway requests, agents, model helpers, and services. This change coordinates their execution and resource lifetimes so retiring a registry does not prematurely dispose dependencies still in use.

flowchart TD
  A[Plugin source and metadata] --> B[Managed plugin instance]
  B --> C[Registry and SDK handles]
  C --> D[Admit work against live owner]
  D --> E[Requests, streams, and services]
  C --> F[Registry retirement]
  F --> D
  E --> G[Drain and release resources]
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - External plugins relying on incidental module filenames, CommonJS cache identities, or repeated evaluation after failure may need adaptation; representative upgrade proof cannot establish compatibility with every such assumption.
  • Resolve merge risk (P1) - The reviewer could inspect recorded observations and source continuity but could not independently retrieve the linked Testbox logs through the permitted network path.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus test growth Reported net production +5,106; tests/support +15,106 The PR explicitly attributes production growth to instance admission, captured-source ownership, and retained cleanup.
Re-review continuity 566 introduced paths unchanged since the previous reviewed head Complete tree comparison supports retaining prior resolved findings and proof assessments across this refresh.

Stored data model

Persistent data-model change detected: serialized state: scripts/lib/bundled-plugin-build-entries.mjs, unknown-data-model-change: extensions/memory-core/src/memory/embeddings.ts, unknown-data-model-change: extensions/memory-core/src/memory/lifecycle.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-provider-lifecycle.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-registry.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager.ts, and 9 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge-risk options

Maintainer options:

  1. Retain the documented loader boundary (recommended)
    Use the existing maintainer-led compatibility discussion and representative upgrade proof to accept captured-source semantics without promising incidental loader behavior.

Technical review

Best possible solution:

Keep one instance lifetime owner while preserving the documented SDK and startup contracts exercised by the recorded fresh-install and stable-upgrade proof.

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

Yes for the targeted retirement scenarios: the source and existing two-Gateway and prepared-publication regressions define concrete paths. This read-only review did not execute a failing current-main reproduction.

Is this the best way to solve the issue?

Yes. Central instance ownership addresses the lifetime mismatch, preserves existing SDK result shapes, and has explicit startup and upgrade evidence; no competing implementation is needed.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is an actively owned lifecycle reliability improvement without evidence of an urgent current user outage.
  • merge-risk: 🚨 compatibility: Captured module identities and retained evaluation failures alter loader behavior that external plugins may incidentally depend on.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Recorded built-Gateway RPC/shutdown and fresh/stable-upgrade runs exercise the changed loader and lifetime owners, with successful requests, preserved state, and natural cleanup; historical final-dispatch evidence also covers retained, unpublished, replaced, and revoked callbacks. Source continuity preserves the prior assessment, while blocked log retrieval remains a reviewer limitation rather than missing contributor proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded built-Gateway RPC/shutdown and fresh/stable-upgrade runs exercise the changed loader and lifetime owners, with successful requests, preserved state, and natural cleanup; historical final-dispatch evidence also covers retained, unpublished, replaced, and revoked callbacks. Source continuity preserves the prior assessment, while blocked log retrieval remains a reviewer limitation rather than missing contributor proof.

Evidence

What I checked:

  • Review continuity verified independently: The complete GitHub tree for previous reviewed head 518125d was compared with local HEAD using blob identities. All 566 merge-base..HEAD paths matched, including absence for deleted paths. The API tree was not truncated. This establishes content continuity, not a claim that hashes substitute for source review. (ddfd8e413e17)
  • Foundation remains absent from main and latest release: Both fetched main and v2026.9.4 lack plugin-instance.ts and retain the older registry-epoch implementation. The supplied merged prerequisites address narrower shutdown problems; none establishes completion of this foundation. (src/plugins/registry-lifecycle.ts:1, a56463d58cbe)
  • Instance admission and cleanup ownership: The instance owner distinguishes ordinary calls, retained consumers, and host cleanup. Retirement closes admission, invalidates ordinary tokens, waits for consumers, and reports bounded disposer failures. Registry authority reads current record ownership rather than trusting an identifier alone. (src/plugins/plugin-instance.ts:31, ddfd8e413e17)
  • Earlier donor-release finding remains addressed: Prepared publications observe registry/cache retirement and release idle holds independently of admitted borrowers. Gateway close releases SDK claims before model and registry disposal; the two-Gateway regression checks that the surviving Gateway remains bound while the closed Gateway rejects calls. (src/agents/prepared-model-runtime.plugin-lifetime.ts:207, ddfd8e413e17)
  • Documented loader compatibility boundary: The architecture documentation explicitly covers captured filenames, instance-local evaluation failures, synchronous TypeScript loading, and Bun's retained native/Jiti path. The SDK preserves bare prepared-completion results through host-owned claims rather than requiring existing callers to adopt a disposer. Public docs: docs/plugins/architecture.md. (docs/plugins/architecture.md:181, ddfd8e413e17)
  • Recorded real behavior and proof limitations: The captured PR body records fresh TypeScript startup and two official-2026.9.2 compatibility flows on tree 840b890d, each with ordered RPCs, healthy status, exactly-once service cleanup, natural exit, and unchanged operator state. It separately identifies the 2026.9.3 upgrade replay and later combined integration evidence. These retain their historical source identities. The four prepared screenshots were inspected and show the donor management UI, not standalone proof of this foundation's runtime invariants. Linked Testbox workflows have cancelled hosting-job conclusions; attempting to read their underlying logs was blocked by the proxy at productionresultssa7.blob.core.windows.net, so workflow status was not treated as scenario success or failure.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • sunlit-deng: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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 (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-11T07:16:28.986Z sha 7598f42 :: blocked before merge. :: none
  • reviewed 2026-09-11T15:27:41.033Z sha 7598f42 :: blocked before merge. :: none
  • reviewed 2026-09-11T16:27:05.602Z sha 099f37e2bc06e058e2abd830ad9653ea2e4b1b18 :: blocked before merge. :: none
  • reviewed 2026-09-11T16:44:15.218Z sha c63ba44 :: blocked before merge. :: none
  • reviewed 2026-09-11T18:45:19.965Z sha 02f8f09 :: blocked before merge. :: none
  • reviewed 2026-09-11T19:14:16.348Z sha eebf9fd3abe9a03ae44bd804092365b3a61dfc8d :: blocked before merge. :: none
  • reviewed 2026-09-11T19:29:19.233Z sha 256d57f34d9fd3fd2e6f2cad99c1114c2fa65743 :: blocked before merge. :: none
  • reviewed 2026-09-11T19:48:22.328Z sha 518125d :: blocked before merge. :: none

obviyus added a commit that referenced this pull request Nov 20, 2026
…am end (#202368)

Root cause: extensions/msteams/src/messenger.ts:120 renders reply text through `getMSTeamsRuntime().channel.text.chunkMarkdownTextWithMode`, but a late Teams stream settlement (`reply-dispatcher.ts:455`, run from `onSettled`) renders its fallback outside the plugin instance runtime slot added in #144252, so the lookup throws `MSTeams runtime not initialized` (src/plugin-sdk/runtime-store.ts:84) and the fallback reply is dropped without a log line.

Related: #59731, #18636, #56040 (earlier lost Teams replies; none proves this exact regression)

## What Problem This Solves

When Teams rejects the end of a streamed reply (for example a partial-mode answer with a Markdown table, where the rendered table no longer matches the already-streamed raw text), OpenClaw is meant to send the rest of the answer as a normal message. Since v2026.10.1 that recovery message is silently dropped, so the user only sees a cut-off, never-finalized stream.

## User Impact

Teams users get the rest of the answer as a message when the stream cannot be completed, instead of a truncated reply with no error.

## Why This Change Was Made

The Teams reply renderer now uses the pure SDK chunker (`openclaw/plugin-sdk/reply-chunking`), which is the same function the runtime chunker re-exports, so rendering no longer depends on the plugin runtime being reachable. Output is unchanged. The test file no longer installs a runtime stub, so the render tests prove rendering works without one; the unused runtime chunker stubs are removed.

Other late msteams send paths checked: the dispatcher's failure system event uses the `core` captured at dispatcher creation, and `sendMSTeamsMessages` reads the runtime only through `user-agent.ts` (already caught). No other late path uses this lookup.

## Evidence

Isolated `ocx src` Gateway with the real msteams plugin, a Teams connector fixture that enforces Microsoft's documented streaming rule (403 ContentStreamNotAllowed when streamed content changes), and a scripted model (two tool calls, then a table answer) in a 1:1 chat, partial streaming mode.

- Before (main e728605): the stream shows "Tools found: | Tool | Scope | ... | whoami | Graph" and is never closed; no fallback message reaches the connector. A temporary log line in a scratch copy showed the fallback (the rest of the table, ending with the `list | MCP` row) was built and render threw `MSTeams runtime not initialized`.
- After: the same run sends the remainder of the table once as a normal message (HTTP 201 from the connector).
- Controls: a successful progress-mode stream sends no extra message; partial-mode plain text is identical before and after.
- Unit: `messenger.test.ts` fails on main with `MSTeams runtime not initialized` and passes with the fix.

Observed proof lines (connector request logs, base and candidate): #202368 (comment)

Merge danger: two-way door, a revert fully undoes it; no state, config or contract change. Blast radius: Microsoft Teams reply rendering only.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 21, 2026
…am end (openclaw#202368)

Root cause: extensions/msteams/src/messenger.ts:120 renders reply text through `getMSTeamsRuntime().channel.text.chunkMarkdownTextWithMode`, but a late Teams stream settlement (`reply-dispatcher.ts:455`, run from `onSettled`) renders its fallback outside the plugin instance runtime slot added in openclaw#144252, so the lookup throws `MSTeams runtime not initialized` (src/plugin-sdk/runtime-store.ts:84) and the fallback reply is dropped without a log line.

Related: openclaw#59731, openclaw#18636, openclaw#56040 (earlier lost Teams replies; none proves this exact regression)

## What Problem This Solves

When Teams rejects the end of a streamed reply (for example a partial-mode answer with a Markdown table, where the rendered table no longer matches the already-streamed raw text), OpenClaw is meant to send the rest of the answer as a normal message. Since v2026.10.1 that recovery message is silently dropped, so the user only sees a cut-off, never-finalized stream.

## User Impact

Teams users get the rest of the answer as a message when the stream cannot be completed, instead of a truncated reply with no error.

## Why This Change Was Made

The Teams reply renderer now uses the pure SDK chunker (`openclaw/plugin-sdk/reply-chunking`), which is the same function the runtime chunker re-exports, so rendering no longer depends on the plugin runtime being reachable. Output is unchanged. The test file no longer installs a runtime stub, so the render tests prove rendering works without one; the unused runtime chunker stubs are removed.

Other late msteams send paths checked: the dispatcher's failure system event uses the `core` captured at dispatcher creation, and `sendMSTeamsMessages` reads the runtime only through `user-agent.ts` (already caught). No other late path uses this lookup.

## Evidence

Isolated `ocx src` Gateway with the real msteams plugin, a Teams connector fixture that enforces Microsoft's documented streaming rule (403 ContentStreamNotAllowed when streamed content changes), and a scripted model (two tool calls, then a table answer) in a 1:1 chat, partial streaming mode.

- Before (main 96278b8): the stream shows "Tools found: | Tool | Scope | ... | whoami | Graph" and is never closed; no fallback message reaches the connector. A temporary log line in a scratch copy showed the fallback (the rest of the table, ending with the `list | MCP` row) was built and render threw `MSTeams runtime not initialized`.
- After: the same run sends the remainder of the table once as a normal message (HTTP 201 from the connector).
- Controls: a successful progress-mode stream sends no extra message; partial-mode plain text is identical before and after.
- Unit: `messenger.test.ts` fails on main with `MSTeams runtime not initialized` and passes with the fix.

Observed proof lines (connector request logs, base and candidate): openclaw#202368 (comment)

Merge danger: two-way door, a revert fully undoes it; no state, config or contract change. Blast radius: Microsoft Teams reply rendering only.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
…am end (#202368)

Root cause: extensions/msteams/src/messenger.ts:120 renders reply text through `getMSTeamsRuntime().channel.text.chunkMarkdownTextWithMode`, but a late Teams stream settlement (`reply-dispatcher.ts:455`, run from `onSettled`) renders its fallback outside the plugin instance runtime slot added in #144252, so the lookup throws `MSTeams runtime not initialized` (src/plugin-sdk/runtime-store.ts:84) and the fallback reply is dropped without a log line.

Related: #59731, #18636, #56040 (earlier lost Teams replies; none proves this exact regression)

## What Problem This Solves

When Teams rejects the end of a streamed reply (for example a partial-mode answer with a Markdown table, where the rendered table no longer matches the already-streamed raw text), OpenClaw is meant to send the rest of the answer as a normal message. Since v2026.10.1 that recovery message is silently dropped, so the user only sees a cut-off, never-finalized stream.

## User Impact

Teams users get the rest of the answer as a message when the stream cannot be completed, instead of a truncated reply with no error.

## Why This Change Was Made

The Teams reply renderer now uses the pure SDK chunker (`openclaw/plugin-sdk/reply-chunking`), which is the same function the runtime chunker re-exports, so rendering no longer depends on the plugin runtime being reachable. Output is unchanged. The test file no longer installs a runtime stub, so the render tests prove rendering works without one; the unused runtime chunker stubs are removed.

Other late msteams send paths checked: the dispatcher's failure system event uses the `core` captured at dispatcher creation, and `sendMSTeamsMessages` reads the runtime only through `user-agent.ts` (already caught). No other late path uses this lookup.

## Evidence

Isolated `ocx src` Gateway with the real msteams plugin, a Teams connector fixture that enforces Microsoft's documented streaming rule (403 ContentStreamNotAllowed when streamed content changes), and a scripted model (two tool calls, then a table answer) in a 1:1 chat, partial streaming mode.

- Before (main e728605): the stream shows "Tools found: | Tool | Scope | ... | whoami | Graph" and is never closed; no fallback message reaches the connector. A temporary log line in a scratch copy showed the fallback (the rest of the table, ending with the `list | MCP` row) was built and render threw `MSTeams runtime not initialized`.
- After: the same run sends the remainder of the table once as a normal message (HTTP 201 from the connector).
- Controls: a successful progress-mode stream sends no extra message; partial-mode plain text is identical before and after.
- Unit: `messenger.test.ts` fails on main with `MSTeams runtime not initialized` and passes with the fix.

Observed proof lines (connector request logs, base and candidate): #202368 (comment)

Merge danger: two-way door, a revert fully undoes it; no state, config or contract change. Blast radius: Microsoft Teams reply rendering only.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit b24f06f)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit bb510f348153fcd9c8c8a788a4e5c985ea57174f)
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…am end (openclaw#202368)

Root cause: extensions/msteams/src/messenger.ts:120 renders reply text through `getMSTeamsRuntime().channel.text.chunkMarkdownTextWithMode`, but a late Teams stream settlement (`reply-dispatcher.ts:455`, run from `onSettled`) renders its fallback outside the plugin instance runtime slot added in openclaw#144252, so the lookup throws `MSTeams runtime not initialized` (src/plugin-sdk/runtime-store.ts:84) and the fallback reply is dropped without a log line.

Related: openclaw#59731, openclaw#18636, openclaw#56040 (earlier lost Teams replies; none proves this exact regression)

## What Problem This Solves

When Teams rejects the end of a streamed reply (for example a partial-mode answer with a Markdown table, where the rendered table no longer matches the already-streamed raw text), OpenClaw is meant to send the rest of the answer as a normal message. Since v2026.10.1 that recovery message is silently dropped, so the user only sees a cut-off, never-finalized stream.

## User Impact

Teams users get the rest of the answer as a message when the stream cannot be completed, instead of a truncated reply with no error.

## Why This Change Was Made

The Teams reply renderer now uses the pure SDK chunker (`openclaw/plugin-sdk/reply-chunking`), which is the same function the runtime chunker re-exports, so rendering no longer depends on the plugin runtime being reachable. Output is unchanged. The test file no longer installs a runtime stub, so the render tests prove rendering works without one; the unused runtime chunker stubs are removed.

Other late msteams send paths checked: the dispatcher's failure system event uses the `core` captured at dispatcher creation, and `sendMSTeamsMessages` reads the runtime only through `user-agent.ts` (already caught). No other late path uses this lookup.

## Evidence

Isolated `ocx src` Gateway with the real msteams plugin, a Teams connector fixture that enforces Microsoft's documented streaming rule (403 ContentStreamNotAllowed when streamed content changes), and a scripted model (two tool calls, then a table answer) in a 1:1 chat, partial streaming mode.

- Before (main e728605): the stream shows "Tools found: | Tool | Scope | ... | whoami | Graph" and is never closed; no fallback message reaches the connector. A temporary log line in a scratch copy showed the fallback (the rest of the table, ending with the `list | MCP` row) was built and render threw `MSTeams runtime not initialized`.
- After: the same run sends the remainder of the table once as a normal message (HTTP 201 from the connector).
- Controls: a successful progress-mode stream sends no extra message; partial-mode plain text is identical before and after.
- Unit: `messenger.test.ts` fails on main with `MSTeams runtime not initialized` and passes with the fix.

Observed proof lines (connector request logs, base and candidate): openclaw#202368 (comment)

Merge danger: two-way door, a revert fully undoes it; no state, config or contract change. Blast radius: Microsoft Teams reply rendering only.

Co-authored-by: Ayaan Zaidi <[email protected]>

Release adaptation: Use existing public SDK chunkMarkdownTextWithMode directly; remove fake runtime test dependency. No protocol or behavior redesign.

(cherry picked from commit b24f06f)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 7320370485b22c18413601ea1d4c48afe4c054d6)
(cherry picked from commit 1ac61645dc785776a4015ddbbc0e2e9ea0974189)
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 channel: discord Channel integration: discord channel: msteams Channel integration: msteams channel: zalo Channel integration: zalo cli CLI command changes commands Command implementations dependencies-changed PR changes dependency-related files docs Improvements or additions to documentation extensions: memory-core Extension: memory-core extensions: openshell gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: beam Beam session sharing plugin plugin: file-transfer plugin: mxc proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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