Skip to content

fix(matrix): restore progress updates when runtime context is unavailable - #155354

Merged
obviyus merged 5 commits into
openclaw:mainfrom
holny:fix/155298-clean
Sep 22, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
holny:fix/155298-clean

Conversation

@holny

@holny holny commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes #155298

What Problem This Solves

Fixes: Matrix progress and tool-activity updates disappear when an asynchronous draft callback cannot access the plugin runtime, even though the final reply still arrives.

User Impact

User impact: Matrix progress streaming can send and edit previews using its retained account settings and client. Final delivery, encryption, mention handling, and oversized-preview fallback keep their existing behavior; no configuration or migration is needed.

Why This Change Was Made

Single-event text preparation now calls the existing SDK table-mode and chunk-limit resolvers directly instead of reaching those same functions through the plugin runtime. The account, configuration, native-table setting, and Matrix event-size cap are unchanged. Multi-message chunking remains outside this repair.

The existing partial-preview test now exercises the actual draft send/edit path with the runtime unavailable. Its shared client fixtures move unchanged into test support so the oversized send suite does not grow further.

Evidence

  • The reporter's normal Gateway before/after logs show Matrix runtime not initialized before the two helper substitutions, then successful encrypted assistant/tool progress sends afterward on OpenClaw 2026.9.5. These are retained reporter observations, not a newly repeated live Matrix run. The SDK exports and runtime facade select the same resolver implementations.
  • On baseline 80b9608a25e191a17e1466d750c2f76a38a38507, the strengthened consumer regression fails at the real draft callback with Matrix runtime not initialized. With the repair, it sends and edits the same threaded draft with retained account limits, keeps mention-looking tool text inert, and stops an oversized preview without another event.
  • Focused validation: 106 send tests, 20 draft-stream tests, and the narrow SDK import guard passed (127 total; 42.36s wall). The strengthened consumer case took 17ms. Extension production/test typechecks, scoped type-aware lint, source-size/assertion ratchets, and whitespace checks passed.
  • The first hosted run exposed six failures in the per-wire authority fixture: it still supplied a five-character limit through the removed runtime lookup. The fixture now sets the existing Matrix chunk-limit configuration instead. All ten real HTTP authority/redirect cases pass, including revocation between chunks, with durable delivery both enabled and disabled (27.65s wall). Its test-type lane and scoped lint/format checks also pass; production code is unchanged.
  • No new live credentials or encrypted transport replay was used. The retained Gateway evidence establishes the reported transport outcome; the local regression covers the consumer boundary with a client fixture. Hosted test timing is not yet available for this revision.

@clawsweeper

clawsweeper Bot commented Sep 22, 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 channel: matrix Channel integration: matrix size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 22, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 8:54 AM ET / 12:54 UTC (Revision 5).

ClawSweeper review

What this changes

The PR restores Matrix progress sends and edits by using existing SDK configuration helpers directly, strengthens draft regression coverage, and updates the affected test fixtures.

Regression provenance

Possible regression — suspected (failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open: this remains a useful, focused fix absent from current main and the latest release. The earlier import finding is resolved, retained runtime evidence supports the repair, and no blocking defect was found.

Priority: P2
Reviewed head: dbc5c02a016429d01e72579613b808932b8ffc48

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant retained runtime proof, meaningful consumer coverage, and no blocking review findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): Retained Gateway logs show the changed Matrix text-preparation path recovering encrypted assistant/tool progress sends after the same helper substitutions on 2026.9.5. The consumer regression supplements that evidence with send/edit, account-limit, mention, and overflow checks; no new live run is claimed, and no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): Retained Gateway logs show the changed Matrix text-preparation path recovering encrypted assistant/tool progress sends after the same helper substitutions on 2026.9.5. The consumer regression supplements that evidence with send/edit, account-limit, mention, and overflow checks; no new live run is claimed, and no stored-data contract changes.
Evidence reviewed 10 items Introduced change and review continuity: The pinned merge-base-to-head diff contains the two resolver substitutions and associated tests. The subsequent change from the previous reviewed head only repairs the authority fixture’s chunk-limit configuration; production behavior is unchanged. The focused markdown-table-runtime import resolves the earlier finding.
Current main still needs the repair: Current main still obtains both formatting resolvers through getMatrixRuntime inside prepareMatrixSingleText despite receiving configuration and account identity directly.
Latest release remains affected: The supplied latest release, v2026.9.5, contains the same two runtime lookups. No fixed release is established.
Findings None None.
Security None None.

How this fits together

Matrix progress drafts turn assistant and tool activity into an evolving room message. Text preparation applies the retained account’s formatting and size settings before the Matrix client sends or edits that message.

flowchart TD
  A[Assistant and tool activity] --> B[Progress draft]
  C[Retained account settings] --> D[Text preparation]
  B --> D
  D --> E{Fits one event}
  E -->|Yes| F[Matrix send or edit]
  E -->|No| G[Normal final delivery]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +4, Tests +71. Total +75 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 7 3 +4
Tests 3 187 116 +71
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 194 119 +75

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #155298
Summary: This PR is the active implementation candidate for the reported Matrix progress failure.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep Matrix preview preparation on the existing SDK resolvers with retained account configuration and the existing send, edit, and overflow behavior.

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

Yes: the retained-config draft callback reaches runtime lookups that throw when Matrix runtime context is unavailable, and the reporter supplies a concrete 2026.9.5 tool-turn reproduction. Current-main runtime execution was not performed in this read-only review.

Is this the best way to solve the issue?

Yes: calling the existing resolvers directly removes the unnecessary runtime dependency without duplicating policy or changing configuration semantics.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Matrix progress visibility is degraded in the reported configuration, while agent execution and final replies continue working.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): Retained Gateway logs show the changed Matrix text-preparation path recovering encrypted assistant/tool progress sends after the same helper substitutions on 2026.9.5. The consumer regression supplements that evidence with send/edit, account-limit, mention, and overflow checks; no new live run is claimed, and no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Retained Gateway logs show the changed Matrix text-preparation path recovering encrypted assistant/tool progress sends after the same helper substitutions on 2026.9.5. The consumer regression supplements that evidence with send/edit, account-limit, mention, and overflow checks; no new live run is claimed, and no stored-data contract changes.

Evidence

What I checked:

  • Introduced change and review continuity: The pinned merge-base-to-head diff contains the two resolver substitutions and associated tests. The subsequent change from the previous reviewed head only repairs the authority fixture’s chunk-limit configuration; production behavior is unchanged. The focused markdown-table-runtime import resolves the earlier finding. (extensions/matrix/src/matrix/send/chunking.ts:192, dbc5c02a0164)
  • Current main still needs the repair: Current main still obtains both formatting resolvers through getMatrixRuntime inside prepareMatrixSingleText despite receiving configuration and account identity directly. (extensions/matrix/src/matrix/send/chunking.ts:188, f4a45a81d798)
  • Latest release remains affected: The supplied latest release, v2026.9.5, contains the same two runtime lookups. No fixed release is established. (extensions/matrix/src/matrix/send/chunking.ts:188, ec9c1a13db89)
  • Existing resolver ownership is preserved: The runtime facade exposes the same implementations exported by markdown-table-runtime and reply-chunking: src/config/markdown-tables.ts and src/auto-reply/chunk.ts. The patch preserves arguments, account overrides, table support, and the Matrix event cap; it introduces no public API or stored-data change. (src/plugins/runtime/runtime-channel.ts:153, dbc5c02a0164)
  • Retained real Gateway evidence: The supplied body of [Bug]: Matrix progress drafts fail with "Matrix runtime not initialized" during tool activity #155298 records repeated runtime errors on Ubuntu with OpenClaw 2026.9.5, followed by encrypted assistant/tool progress events reaching sent state after the same two helper substitutions. The PR explicitly retains these observations rather than claiming a new live run. Its captured sourceRevision is 1d33f363cf2a94a74a077ce623fd6fef1ef89412b4a05529877b4698d346e200.
  • Production consumer regression: The strengthened test invokes the actual draft stream with the Matrix runtime cleared and real resolver implementations. It checks threaded creation, replacement edits, inert mention-looking text, account-specific limits, and oversized-preview fallback. The body reports baseline failure and passing focused validation; this read-only review did not execute tests. (extensions/matrix/src/matrix/send.test.ts:1484, dbc5c02a0164)

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: 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 (4 earlier review cycles)
  • reviewed 2026-09-22T02:11:40.864Z sha c59eb2e477fd43e7437b585b71714df8dd14631e :: needs changes before merge. :: [P2] Import the table helper from the focused SDK subpath
  • reviewed 2026-09-22T08:11:56.523Z sha 39d38d3 :: needs changes before merge. :: none
  • reviewed 2026-09-22T08:38:46.908Z sha 39d38d3 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-22T12:29:45.713Z sha 521fd5e :: needs maintainer review before merge. :: none

…trixSingleText

The progress callback path calls prepareMatrixSingleText asynchronously, but
getMatrixRuntime() throws 'Matrix runtime not initialized' in that context.
Replace the two getMatrixRuntime().channel.text calls with the equivalent
direct SDK helpers (resolveMarkdownTableMode, resolveTextChunkLimit) that
accept the necessary parameters and do not require runtime context.

Also add vi.mock for the SDK subpaths in the test file so the existing
test mocks (resolveMarkdownTableModeMock, resolveTextChunkLimitMock) are
properly applied to the new code paths.

Closes openclaw#155298
…oundary guard

The config-boundary contract guard blocks broad
openclaw/plugin-sdk/config-runtime imports. Import resolveMarkdownTableMode
from markdown-table-runtime and move the test mock to the same subpath.
@clawsweeper clawsweeper Bot added 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. and removed 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 22, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 22, 2026
@holny

holny commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

The checks-node-changed-extensions-config-6 shard failures are in send.authority.integration.test.ts (per-wire send authority guards). I reproduced these on a pristine origin/main checkout with none of my changes applied — same 6 failures / 4 passes. They're unrelated to this PR and look like a main-side regression or shard-order issue.

checks-fast-baseline-ratchets failures also reproduced on the clean main checkout in the same run. The repair itself is covered by send.test.ts (106/106) and the contract guard (1/1), both green locally and in the earlier CI run at 39d38d3c1ee.

@obviyus obviyus changed the title fix(matrix): use SDK helpers instead of getMatrixRuntime in prepareMatrixSingleText fix(matrix): restore progress updates when runtime context is unavailable Sep 22, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: imessage Channel integration: imessage app: ios App: ios app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime labels Sep 22, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: M and removed docs Improvements or additions to documentation channel: imessage Channel integration: imessage app: ios App: ios app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling extensions: qa-lab extensions: codex extensions: browser size: XL labels Sep 22, 2026
@obviyus
obviyus merged commit 00aa7a6 into openclaw:main Sep 22, 2026
102 checks passed
@obviyus

obviyus commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Merged as 00aa7a6. Matrix progress drafts now use their retained configuration without requiring the plugin runtime. The runtime-unavailable send/edit regression and all ten HTTP authority cases pass; required CI and exact-head review passed. Thanks @holny for the fix and @mykhul for the Gateway before/after evidence.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
…able (openclaw#155354)

Closes openclaw#155298

## What Problem This Solves

Fixes: Matrix progress and tool-activity updates disappear when an asynchronous draft callback cannot access the plugin runtime, even though the final reply still arrives.

## User Impact

User impact: Matrix progress streaming can send and edit previews using its retained account settings and client. Final delivery, encryption, mention handling, and oversized-preview fallback keep their existing behavior; no configuration or migration is needed.

## Why This Change Was Made

Single-event text preparation now calls the existing SDK table-mode and chunk-limit resolvers directly instead of reaching those same functions through the plugin runtime. The account, configuration, native-table setting, and Matrix event-size cap are unchanged. Multi-message chunking remains outside this repair.

The existing partial-preview test now exercises the actual draft send/edit path with the runtime unavailable. Its shared client fixtures move unchanged into test support so the oversized send suite does not grow further.

## Evidence

- [The reporter's normal Gateway before/after logs](openclaw#155298) show `Matrix runtime not initialized` before the two helper substitutions, then successful encrypted assistant/tool progress sends afterward on OpenClaw 2026.9.5. These are retained reporter observations, not a newly repeated live Matrix run. The SDK exports and runtime facade select the same resolver implementations.
- On baseline `fbd27c6a44334575ea4afb79656264c9f56ea4a4`, the strengthened consumer regression fails at the real draft callback with `Matrix runtime not initialized`. With the repair, it sends and edits the same threaded draft with retained account limits, keeps mention-looking tool text inert, and stops an oversized preview without another event.
- Focused validation: 106 send tests, 20 draft-stream tests, and the narrow SDK import guard passed (127 total; 42.36s wall). The strengthened consumer case took 17ms. Extension production/test typechecks, scoped type-aware lint, source-size/assertion ratchets, and whitespace checks passed.
- The first hosted run exposed six failures in the per-wire authority fixture: it still supplied a five-character limit through the removed runtime lookup. The fixture now sets the existing Matrix chunk-limit configuration instead. All ten real HTTP authority/redirect cases pass, including revocation between chunks, with durable delivery both enabled and disabled (27.65s wall). Its test-type lane and scoped lint/format checks also pass; production code is unchanged.
- No new live credentials or encrypted transport replay was used. The retained Gateway evidence establishes the reported transport outcome; the local regression covers the consumer boundary with a client fixture. Hosted test timing is not yet available for this revision.

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

channel: matrix Channel integration: matrix P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

[Bug]: Matrix progress drafts fail with "Matrix runtime not initialized" during tool activity

2 participants