Repository navigation
fix(matrix): let follow-ups steer active turns - #128907
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 25, 2026, 11:03 AM ET / 15:03 UTC. ClawSweeper reviewWhat this changesRoutes Matrix follow-ups and authorized text Merge readinessKeep open: the previous P1 remains. An authorized text Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherMatrix messages enter the Matrix plugin and then shared reply admission, which resolves the session, persists the user turn, and applies active-run queue policy. Explicit steering must select the active conversation before that pipeline can associate it with the correct embedded agent run. flowchart LR
A[Matrix follow-up] --> B[Matrix monitor]
B --> C[Prepared reply admission]
C --> D[Active session routing]
D --> E[Transcript persistence]
D --> F[Embedded agent steering]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +65, Tests +451. Total +516 across 15 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use one canonical active embedded-owner query for slash-to-direct routing that recognizes both reply-operation and active-handle ownership, then add a regression for the handle-only interval. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main explicitly supports an active embedded run without a reply operation, while the new slash-target resolver requires that operation. The needed regression is a handle-only direct/DM run plus an authorized Is this the best way to solve the issue? No. The PR’s prepared-turn design is the right direction, but the active-owner lookup must use the same embedded-run state that current main uses for operation-free admission. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b0c27e2d8f57. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
4afb4e4 to
7e042db
Compare
|
The original PR body is now updated with robust real-world, end-to-end proof for both steering paths: ordinary Matrix follow-up under configured The branch also now includes the minimal test-only type/lint repair at exact head @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Note to maintainers regarding P1: The failing resolver at issue here is in shared src/auto-reply/reply/explicit-steer-routing.ts, and the :slash: alias pattern exists for Telegram, Discord, Slack, Matrix, and other shared reply-runtime callers. Matrix exposed the bug and #128907’s Matrix path is the PR context, but the operation-free active-owner blind spot is a shared /steer problem, already present on main. That strongly supports suggesting that it should be handled as a systemic follow-up rather than making this Matrix persistence PR absorb it. Note: AI-assisted, but I did repeatedly review the PR, worked closely on it, tested it repeatedly on my real-world installation, and also reviewed the P1 (and inquired about its origin / uniqueness to Matrix), which was what led to the discovery that it is not unique to Matrix. |
b269c7a to
f004390
Compare
|
Landing verification for exact head
No known proof gaps remain. |
|
Merged via squash.
|
* fix(matrix): let follow-ups reach active turns * fix(auto-reply): persist explicit steer turns * test(matrix): stabilize active steering admission * test: fix active steering type checks * fix(auto-reply): route steer to active embedded owner --------- Co-authored-by: Benjamin Badejo <[email protected]> Co-authored-by: Josh Lehman <[email protected]> Co-authored-by: Josh Lehman <[email protected]>
AI-assisted: yes.
Related: #110568, #119287
What Problem This Solves
Matrix users can send a follow-up while an agent turn is active, but two different admission paths prevented the existing steering machinery from behaving end to end:
/steercommand could reach and change the active agent run while bypassing the normal prepared-turn persistence path. The command therefore did not create the durable user transcript row that session history and the Control UI project.The second failure was observable on a real Matrix session: the explicit
/steerchanged the active Codex run, but the command itself was absent from the durable OpenClaw transcript and from the Control UI session view.Why This Change Was Made
The Matrix handler already claims inbound events through the shared replay guard, but it did not carry that ownership into the shared turn-adoption lifecycle. Shared reply admission could therefore hold a second visible Matrix turn until the first operation settled, before active-run queue policy evaluated it.
The first commit adapts that exact replay claim to the existing exclusive turn-adoption lifecycle:
The explicit command path had a separate problem. It directly injected text into the active run and returned an immediate acknowledgement, skipping the established prepared reply path that supplies transcript recording, stable queue identity, media, abort propagation, and adoption lifecycle handling. The second commit makes authorized
/steerstrip only its command prefix, preserve its body, and continue through the normal prepared-turn path with a turn-localsteerqueue override. Legacy authorized text-slash direct/DM alias resolution is preserved before that continuation.The result uses the same queue-policy, run-adoption, transcript, and race-fallback contracts as an ordinary prepared follow-up. It does not add Matrix-specific steering semantics, change default queue policy, add configuration, or alter the durable replay-key format.
User Impact
/steer <message>reaches that same path with<message>intact and is persisted as a normal user turn when adopted.steerTargetRunId.Idle Matrix messages, access and mention gates, room-history ordering, duplicate suppression, and non-Matrix channel behavior remain on their existing paths.
Evidence
Frozen review base:
dca05ea39ac4a69a595dd2aa6a94f9a3ba0e2d44Exact submitted head:
df949a9c792d725c2119f40ea4751759079bad8dSecond production proof after co-installation with Matrix turn-taking
The unchanged four-commit PR head
df949a9c792d725c2119f40ea4751759079bad8dwas also applied in the production composition ending atc2c1b914710736dbf5f7a68e525a59d57a211bd3; all four submitted and installed commits have pairwise-identical stable patch IDs. This composition also contained the current Matrix multi-agent turn-taking candidate, providing a compatibility exercise rather than an isolated handler test.At 16:24:08 IDT, a normal Matrix event (redacted ID
$nZn6...) selected Forge for a multi-tool operational assessment. After Forge's original run had started and emitted progress plus its first tool call, a second ordinary Matrix event (redacted ID$EOm...) changed the required final sentence. The configured queue mode wassteer; the source event did not use a command prefix.steerTargetRunIdequal to the already-active runc4b9a660-72ae-49df-85bf-b72e808585bf.turn/steerrequest13, modeSteer, client identity ending insteer:1, and the expected active Codex turn. The update was injected into that turn after the first assistant progress message and first tool call, rather than becoming a second run.Recommendation: review the current settings.5599f793...) tied to the original trigger, progressing from revision 0 through revision 17final; no second response root or duplicate final was emitted.This independently reconfirms ordinary configured steering, same-run durable persistence, Codex
turn/steerdelivery, successful terminal completion, and compatibility with the enhanced multi-agent Matrix handler on the submitted PR head.The submitted range contains four focused commits:
8946c1183c305c366ab9f496e1d6fe5bd415c1a8— Matrix replay-claim/adoption lifecycle.7e042db452e6c5a58b9bc188f0b31b8da27faf6a— durable explicit-steer prepared-turn routing.b35b5e48887c3a5ccb89babc89ecf5e265c2ab0a— deterministic wait hardening for the active-turn regression.df949a9c792d725c2119f40ea4751759079bad8d— test-only type and lint narrowing for the new active-steering coverage.Ordinary Matrix follow-up
9b36c8bc56ab990266ba3aca245cdb552b5ba09e, the focused regression failed both parameterized cases: after the second Matrix event resolved, the shared reply resolver had still been called only once (expected 2, received 1). This reproduced the block before queue-policy evaluation for both configuredsteermode and explicit/steeringress.extensions/matrix/src/matrix/monitor/handler.active-turn-steering.test.tspasses 4/4 after hardening its timing-sensitive initial admission wait with a bounded CI-load-aware window. The second event reaches real shared reply admission before the first settles;CommandBodyis preserved; the exact top-level lifecycle arrives with exclusive admission; late adoption commits the replay claim once; and late abandonment releases it once without handler double-settlement.Explicit
/steerpersistence and Control UI projectionReal fail-before observation: during a real Matrix turn backed by the native Codex app-server, an explicit
/steerinstruction was accepted by the active run and changed its announced work/order. Read-only inspection afterward found no corresponding durable OpenClaw user transcript row, so the Control UI session view also had no command to display. A later ordinary follow-up in the same run did produce a durable row withsteerTargetRunId, isolating the defect to the explicit command's direct-injection path rather than Matrix delivery or Control UI filtering.Automated pass-after coverage on the submitted head: the focused command and end-to-end regressions establish that an authorized explicit steer:
steeroverride;steerTargetRunId;Real Matrix after-fix proof for both steering paths
The submitted changes were installed in a production candidate at
73657a73c372dee6596dfff7cd7b204875e042caand exercised end to end through the real self-hosted Matrix → OpenClaw → Codex app-server stack. The test used the existing System Maintenance room, Sentinel's production Matrix account, OpenClaw sessioncf4ef821-6010-4f97-bf82-1f0753471dfd, and active OpenClaw run091127a5-3d06-475d-9794-a87101c2aa89.The initial Matrix request deliberately started a multi-tool task: list all 50 U.S. states alphabetically, create a DOCX, and convert it to PDF. While that original run remained active, the user sent two follow-ups through Matrix:
An ordinary follow-up, relying on the configured default
steerqueue mode:An explicit command:
Read-only correlation across the Matrix server, Sentinel's durable OpenClaw transcript, and the Codex app-server log establishes the exact path for each source event.
Ordinary configured-steer follow-up
$5rGt…was stored by Synapse at2026-08-25 06:39:49.985 IDTwith bodyActually, reverse alphabetical order.and no command prefix.357, message81e0177e…, with the same Matrix transport event ID and the same visible content.__openclaw.steerTargetRunId = 091127a5-3d06-475d-9794-a87101c2aa89.06:39:50 IDT, the Codex app server recordedturn/steerrequest13, client identityopenclaw:<turn>:steer:1,mode: Steer, and the expected active Codex turn01a03700-832b-7a90-8e3d-0f6b1a36269a, carrying the exact follow-up payload.Explicit
/steerfollow-up$D27d…was stored by Synapse at2026-08-25 06:40:40.332 IDTwith body/steer actually alphabetical order.373, message9e0c4924…, with visible contentactually alphabetical orderand the same source Matrix transport event ID.__openclaw.steerTargetRunId = 091127a5-3d06-475d-9794-a87101c2aa89.06:40:41 IDT, the Codex app server recordedturn/steerrequest14, client identityopenclaw:<turn>:steer:2,mode: Steer, and the same expected active Codex turn, carrying the stripped payload.The Control UI screenshot shows both follow-ups as distinct durable user rows in that same live session. In particular, the second row displays the explicit command's stripped payload, proving that the command no longer disappears after direct injection:
The screenshot's source PNG is stored outside the PR diff on the fork-only evidence branch
codex/pr-evidence-128907-20260825; its local and GitHub-hosted SHA-256 hashes both equalbc83725e0e63fdaaab3d8f91d505e30b9730d95d5e8d84bc959b7a349339a918.The same active run then completed the requested task end to end. Its durable transcript recorded the second correction, regenerated artifacts, validation, progress
5/5, Matrix attachment delivery receipts, and a terminal row at sequence425withrunTerminal = truefor the same run ID.This production trace exercises the complete regression boundary:
Neither source message disappeared, neither was duplicated, both targeted the same active OpenClaw run and Codex turn, and the final artifacts reflected the latest steering instruction.
Focused verification on the exact head
oxlint, repository formatting check, andgit diff --checkpass.Real Matrix after-fix proof for ordinary configured steering
On 2026-08-25, the lifecycle patch was cleanly cherry-picked into a production OpenClaw installation connected to a real self-hosted Matrix deployment and exercised with production Matrix accounts. The production commit was
fb4184a99ccb89a20bcdcc570fa7e264bf638938; its stable patch-id was7e011d63b334405665e880c60ec0e519837e8d4f, exactly matching the then-submitted lifecycle head4afb4e40b5438a06e2fe9fe802243508c544c35e. The checkout was clean and the configured global queue mode wassteer.The user began a normal Matrix turn requesting an alphabetically ordered result. After the active turn had already progressed far enough to show forward-order interim output, the user sent an ordinary Matrix follow-up changing the requirement to reverse alphabetical order. This was a real Matrix ingress event, not a Control UI injection. The final Matrix response honored the follow-up and returned the reverse ordering.
The redacted durable trace establishes that this was adoption into the original active run, not a queued second run:
{ "trace": "real-matrix-production-after-fix", "queueMode": "steer", "activeRunStartedAt": "2026-08-25T01:28:06.704Z", "followupTranscriptCreatedAt": "2026-08-25T01:29:13.472Z", "activeRunEndedAt": "2026-08-25T01:29:32.789Z", "followupWasMatrixTransport": true, "followupSteerTargetMatchedActiveRun": true, "targetStartedBeforeFollowup": true, "targetEndedAfterFollowup": true, "distinctRunStartsInWindow": 1, "onlyTargetRunStarted": true, "assistantRowsAfterFollowup": 1, "supersededForwardAssistantRowsAfterFollowup": 0, "reverseOrderAssistantRowsAfterFollowup": 1, "transcriptIdentityRowsForFollowup": 1, "identitySequenceMatchedTranscript": true, "matrixReplayRowsForExactTransportTuple": 1, "replayKeyMatchedExactTransportTuple": true, "replayClaimWasRecordedDuringActiveRun": true, "replayClaimWasUnexpiredAtVerification": true }Room, homeserver endpoint, account identity, credentials, and raw event/session/run identifiers are intentionally omitted. The trace was derived from the Matrix client observation plus read-only inspection of the production agent transcript/event-identity store, run lifecycle records, and Matrix inbound replay store after the turn completed.
Downstream protocol audit
OpenAI Codex at
c941572917b9295c7318b28aab27709202a645c7definesturn/steerwith a required active-turn precondition inTurnSteerParams; the app server validates and dispatches it inturn_processor.rs, and core validates the active regular turn and queues pending input inturn_input.rs.Scope
The exact frozen range is 15 files,
+682/-177. It introduces no schema migration, dependency, or changelog change.