Repository navigation
Conversation
|
Thanks for the contribution. I reviewed the branch, and this PR is not a good landing base for OpenClaw. Close as low-signal/unmergeable: the Matrix idea is useful and still tracked separately, but this branch is conflicting, release-based, missing real behavior proof, and mixes the feature with unrelated release workflow, changelog, updater, gateway, and live-test churn plus concrete patch blockers. So I’m closing this PR rather than keeping an unmergeable branch open. A new narrow PR that carries only the useful part is welcome. Review detailsBest possible solution: Close this branch and keep the remaining Matrix product work in the canonical narrow issue, then invite a fresh main-based Matrix-only PR that defines the opt-in contract, avoids release/ops churn, uses approved state/plugin seams, and includes real Matrix proof. Do we have a high-confidence way to reproduce the issue? Not applicable for the requested feature as a live bug reproduction. The merge blockers are source-reproducible from the PR branch, and the narrower current-main Matrix gap is already source-proven in the linked canonical issue. Is this the best way to solve the issue? No. The best solution is not to repair this mixed release-based branch; it is to submit a narrow main-based Matrix PR after maintainers settle the opt-in config/default/state contract. Security review: Security review needs attention: Security review needs attention because this Matrix PR also changes secret-bearing release/Telegram package workflow behavior and defaults Matrix AI room-context decisions on.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against b5999bc6a07d. |
Greptile SummaryThis PR adds AI-gated participation control and final-reply freshness gating for Matrix multi-bot rooms, with speculative parallel execution, durable room-scoped directives, thread-aware stale-draft detection, and full schema/config/test coverage for the new
Confidence Score: 4/5Mergeable with caution — two open P1 findings from the prior review round remain unresolved; new finding is P2 only. Score is capped at 4 because two P1 issues identified in prior review threads are still present: the pre-draft holdback path unconditionally suppresses turns for extensions/matrix/src/matrix/monitor/handler.ts (pre-draft holdback freshness mode handling), extensions/matrix/src/matrix/monitor/participation-policy.ts (resolveParticipationDecision fallback + malformed schema prompt) Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/matrix/src/matrix/monitor/participation-policy.ts
Line: 314
Comment:
**Malformed JSON schema in AI participation system prompt**
The schema description string passed to the model has missing closing quotes on the `includeAgentIds` and `excludeAgentIds` fields:
```
"includeAgentIds?:string[], ← missing closing "
"excludeAgentIds?:string[], ← missing closing "
```
Because neither field is closed, a model that parses this literally as JSON sees `includeAgentIds?:string[],` and the rest as a single unclosed key, which garbles the remaining fields. Even models that infer the intent may produce lower-quality JSON output (e.g. omitting those optional arrays or misclassifying `persistence`), silently degrading participation decisions.
The corrected schema should use consistent quoting:
```
{"action":"none|open|subset_only|exclude_subset|silence","includeAgentIds?":["string"],"excludeAgentIds?":["string"],"persistence":"message|room","clearsStoredPolicy?":boolean}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (2): Last reviewed commit: "matrix: overlap participation AI with dr..." | Re-trigger Greptile |
| } else if (preDraftRoomChanged) { | ||
| logVerboseMessage( | ||
| `matrix suppressing turn before draft start after holdback room=${roomId}`, | ||
| ); | ||
| logFreshnessDecision({ | ||
| stage: "pre-draft-holdback", | ||
| action: "suppress", | ||
| roomChanged: true, | ||
| }); | ||
| await commitInboundEventIfClaimed(); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Pre-draft holdback ignores
revise and auto freshness modes
When draftHoldbackMs > 0 and the room changes during the holdback window, every mode except "send-as-is" falls into the else if (preDraftRoomChanged) branch and suppresses the turn entirely. This directly contradicts the configured mode semantics:
"revise"— documented as "rerun/revise the reply before sending", but here the turn is silently dropped before a draft is ever started."auto"— documented as "let configured freshness logic decide among allowed final actions", but the AI is never consulted; it suppresses unconditionally.
Only "suppress" is handled correctly by this path. The branch should check freshnessMode === "suppress" explicitly, and let "revise" / "auto" continue (allowing the freshness-aware resolver and final-gate to take over later in the pipeline).
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/matrix/src/matrix/monitor/handler.ts
Line: 2360-2371
Comment:
**Pre-draft holdback ignores `revise` and `auto` freshness modes**
When `draftHoldbackMs > 0` and the room changes during the holdback window, every mode except `"send-as-is"` falls into the `else if (preDraftRoomChanged)` branch and suppresses the turn entirely. This directly contradicts the configured mode semantics:
- `"revise"` — documented as "rerun/revise the reply before sending", but here the turn is silently dropped before a draft is ever started.
- `"auto"` — documented as "let configured freshness logic decide among allowed final actions", but the AI is never consulted; it suppresses unconditionally.
Only `"suppress"` is handled correctly by this path. The branch should check `freshnessMode === "suppress"` explicitly, and let `"revise"` / `"auto"` continue (allowing the freshness-aware resolver and final-gate to take over later in the pipeline).
How can I resolve this? If you propose a fix, please make it concise.| const currentDirective = | ||
| params.currentDirective ?? | ||
| (typeof params.text === "string" | ||
| ? parseParticipationDirective({ text: params.text, availableAgents: params.availableAgents }) | ||
| : undefined); |
There was a problem hiding this comment.
Silent deterministic fallback inside
resolveParticipationDecision
When currentDirective is undefined and a text parameter is provided, the function silently falls back to parseParticipationDirective (deterministic parsing). This contradicts the explicit design constraint that "ai-first" must not fall back to deterministic decision-making.
While no current call site in handler.ts passes text without also providing a resolved currentDirective, the optional parameter makes it easy to accidentally invoke the fallback — for example, from tests or future call sites that pass raw message text. Removing the text parameter and the inline deterministic fallback from this function would make the "no silent fallback" contract explicit and hard to violate.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/matrix/src/matrix/monitor/participation-policy.ts
Line: 378-382
Comment:
**Silent deterministic fallback inside `resolveParticipationDecision`**
When `currentDirective` is `undefined` and a `text` parameter is provided, the function silently falls back to `parseParticipationDirective` (deterministic parsing). This contradicts the explicit design constraint that `"ai-first"` must not fall back to deterministic decision-making.
While no current call site in `handler.ts` passes `text` without also providing a resolved `currentDirective`, the optional parameter makes it easy to accidentally invoke the fallback — for example, from tests or future call sites that pass raw message text. Removing the `text` parameter and the inline deterministic fallback from this function would make the "no silent fallback" contract explicit and hard to violate.
How can I resolve this? If you propose a fix, please make it concise.|
Closing this noisy release-based attempt. A clean main-based PR is staged locally, but pushing it requires the GitHub token to include workflow scope because upstream main now contains workflow files. |
|
Reopened. Note, this should have been marked [AI-assisted]; will be mindful of that in the future. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper applied the proposed close for this PR.
|
feat(matrix): add AI-gated participation and final-reply freshness controls
Summary
/steer/ command exemptions.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
Regression Test Plan (if applicable)
extensions/matrix/src/matrix/monitor/handler.test.tsextensions/matrix/src/matrix/monitor/latest-visible.test.tsextensions/matrix/src/matrix/monitor/participation-state.test.tsextensions/matrix/src/matrix/account-config.test.tsextensions/matrix/src/config-schema.test.ts/steerand explicit command paths remain exempt from participation suppression.User-visible / Behavior Changes
Matrix channel config now supports two optional blocks:
participationandfreshness.streamingrecommendation for multi-bot roomsFor rooms with many bots, users should leave Matrix
streamingset toofffor best results. Non-streamed replies give the final participation/freshness gate a chance to decide before any visible partial output is emitted.Supported
streamingvalues remain:"partial"— stream partial visible output."quiet"— stream in quiet mode."off"— do not stream partial visible output; recommended for rooms with many bots.true/false— legacy boolean form.participationconfigControls whether a Matrix bot should participate in a group-room turn when users give room-level participation instructions such as “AgentAlpha only”, “AgentAlpha and AgentBeta”, “everyone except AgentGamma”, or “no bots reply”.
participation.enabled(boolean, optional)participation.strategy("ai-first" | "deterministic" | "ai-delivery-gate" | "deterministic-then-ai", optional)"ai-first": uses the configured model to interpret participation intent first. This mode does not silently fall back to deterministic decision-making."deterministic": uses deterministic participation parsing only."ai-delivery-gate": allows drafting to proceed and applies an AI participation decision at delivery time."deterministic-then-ai": tries deterministic parsing first, then uses AI when deterministic parsing is insufficient.participation.model(string, optional)participation.minRoomMembers(integer >= 0, optional)participation.minAgentMembers(integer >= 0, optional)participation.persistence("off" | "explicit" | "always", optional)"off": participation directives are not persisted beyond the immediate decision."explicit": only explicitly persistent directives are stored."always": room participation policy is stored whenever a directive produces a durable room policy.freshnessconfigControls what happens when a bot has produced a final draft but newer visible Matrix room activity appears before delivery.
freshness.enabled(boolean, optional)freshness.mode("revise" | "suppress" | "auto" | "send-as-is", optional)"revise": if newer visible room activity arrives, rerun/revise the reply before sending."suppress": if newer visible room activity arrives, suppress the stale reply."auto": let configured freshness logic decide among allowed final actions."send-as-is": detect/log freshness state but send the existing draft unchanged.freshness.scope("room" | "thread-aware", optional)"room": any newer visible room activity can make the draft stale."thread-aware": considers thread/reply context and ignores unrelated activity where appropriate.freshness.draftHoldbackMs(integer >= 0, optional)freshness.model(string, optional)freshness.minRoomMembers(integer >= 0, optional)freshness.minAgentMembers(integer >= 0, optional)freshness.allowedFinalActions(Array<"revise" | "suppress" | "send-as-is">, optional, min length 1)"revise": rewrite the reply using refreshed room context."suppress": do not send the reply."send-as-is": send the existing draft unchanged.freshness.aiDeterminesFinalAction(boolean, optional)freshness.finalAction("revise" | "suppress" | "send-as-is", optional)Example intent phrases this supports in busy rooms:
Diagram (if applicable)
Security Impact (required)
No)No)Yes)No)Yes)Yes, explain risk + mitigation:Repro + Verification
Environment
streaming,participation, andfreshnesschannel/account config.Steps
AgentAlpha,AgentBeta, andAgentGamma.streamingset toofffor the clearest multi-bot behavior.Expected
/steerare not suppressed by participation control.freshnessconfiguration.streaming: "off", because no partial visible reply is emitted before the final gate.Actual
Evidence
Attach at least one:
Verification run locally:
Human Verification (required)
What you personally verified (not just CI), and how:
v2026.4.26./steerand explicit command paths remain exempt.AgentAlpha,AgentBeta, andAgentGammaare used in examples instead of deployment-specific names.Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes)Yes)No)streaming: "off"for best results.matrix.participationchannel/account config.matrix.freshnesschannel/account config.Risks and Mitigations
Risk: AI participation/freshness calls may add latency at reply time.
Risk: Incorrect participation classification could suppress a useful reply.
/steerremain exempt.Risk: Stale-draft freshness checks could over-trigger in active rooms.
Risk: Durable room participation state could store user text unnecessarily.