Repository navigation
fix(agents): a member on the global session gets a reply again - #204335
Conversation
…ep-warm notes them Keep-warm candidate noting threw for agent-less global transcript receipts inside committed-fact installation, which invalidated a member's retained session facts and failed their turn. Regression from #204219. Co-authored-by: obviyus <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR skips keep-warm candidate creation when a transcript receipt supplies neither an agent ID nor an agent-qualified session key. Example: A member sends a message to the main agent's global session.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR narrowly repairs a source-confirmed member-reply regression still present on main; no introduced defect was found, but failing CI remains unattributed. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCron maintenance consumes committed session-change notifications and records in-memory keep-warm candidates; its synchronous listener shares fact installation with the retained sharing facts used by member turns. flowchart TD
A[Member sends message] --> B[Gateway member turn]
B --> C[Transcript commit receipt]
C --> D[Session fact installation]
D --> E[Keep warm candidate listener]
E --> F[Skip receipt without agent identity]
D --> G[Retained sharing facts]
G --> H[Assistant reply completes]
Technical reviewBest possible solution: Retain the existing candidate owner and classification guard so optional keep-warm bookkeeping cannot invalidate valid agent-less transcript receipts. Do we have a high-confidence way to reproduce the issue? The current-main receipt producer, unconditional listener, throwing resolver, and invalidation consumer establish the failure path; the author reports matching before/after Gateway test results, and this review executed no target code. Is this the best way to solve the issue? This is the smallest complete repair at the existing bookkeeping owner: it reuses the canonical key classifier, preserves identifiable-agent candidates, and adds a distinct fact-installation regression without introducing another owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7cbf1585ed73. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +5, Tests +21. Total +26 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 23, 2026, 9:24 PM ET / November 24, 2026, 02:24 UTC. |
|
Maintainer override: every red check on f980b81 also fails without this change. This PR changes one guard in keep-warm candidate noting plus one test. Because the file is under
The test this PR fixes, |
|
Landed in 6312567. Since #204219, keep-warm candidate noting threw for transcript receipts on the |
…law#204335) ## Result A member who sends on the `global` session gets a reply again. Since openclaw#204219, the reply turn could end with `status: error, stopReason: "rpc"` and the message "OpenClaw couldn't finish this reply", and no assistant entry was written. This happened even with `agents.defaults.promptCacheKeepWarm: false`. ## Cause openclaw#204219 added a committed-facts listener in `src/cron/maintenance.ts` that calls `notePromptCacheKeepWarmChange` for every transcript change. That function resolved the agent with `resolveAgentIdFromSessionKey(sessionKey)`. Transcript receipts (`publishCommittedSessionTranscriptReceipts`) name no `agentId`, and for the `global` key that resolver **throws** ("Session key does not contain an agent id"). The listener runs inside committed-fact installation (`sessionChanges.emitBatch` → `publishSqliteCommittedState`). A throw there fails the batch, and the publication's `invalidate()` sends every fact listener a copy of the change with `factsInvalidated: true`. The member turn's retained session-sharing facts (`prepareSessionMutationFacts`, followed by `chat.send`) treat that as a foreign change and invalidate themselves. The next `assertTargetCurrent` then throws `SessionMutationAuthorizationChangedError: session changed before chat.send`, and the run settles as a failure. The listener is registered whether keep-warm is on or off. That is why the switch did not help. Trace (runtime probes, removed): run error → `agent-runner-error-handler` `SessionMutationAuthorizationChangedError` → `readCurrent` saw `SessionMutationFactsUnavailableError` → facts `invalidate()` on `{ sessionKey: "global", scope: "transcript", factsInvalidated: true }` → `sqlite-post-commit` `invalidate` ← `publishCommittedSessionTranscriptReceipts`. Calling `notePromptCacheKeepWarmChange` directly with `global` throws. ## Fix `notePromptCacheKeepWarmChange` returns without a candidate when the change names no agent and the key is not an agent key. It no longer throws inside fact installation. Agent keys (`agent:<id>:…`) and changes that carry `agentId` behave as before. Accepted edge case: a `global` or legacy-key transcript receipt without an `agentId` does not schedule a keep-warm ping. Before this fix, such a receipt failed the commit instead. ## Evidence - `src/gateway/server.chat-membership-authority.product.test.ts`: fails on `4ec95ada` (openclaw#204219; the parent `6183e30b` passes), passes on this head. The test starts a real Gateway server on a scratch port with a TLS WebSocket and a trusted-proxy member identity, and sends to a provider HTTP server. A member's `chat.send` and `agent` turns on `global` for both agents now get replies. - New `src/cron/maintenance-lifecycle.test.ts` case: a `global` transcript change installs once, with no `factsInvalidated` re-delivery. It fails on `4ec95ada` (3 deliveries) and passes on the head. - openclaw#204219's keep-warm tests still pass: `prompt-cache-keep-warm.test.ts`, `maintenance-lifecycle.test.ts` ("wakes keep-warm … when an interactive session's transcript settles"), `session-fork-request.test.ts`, `cache-ttl.test.ts`, `openai-prompt-cache.test.ts`, `anthropic-transport-stream.prewarm.test.ts`. - Gap: I did not repeat openclaw#204219's paid provider prewarm probes. This change touches only candidate noting for agent-less non-agent keys, and that path never produced a ping. - CI: the only reds also fail on `main` or in unrelated PRs (see the Maintainer override comment). Local ClawSweeper: patch is correct, no findings. Co-authored-by: Ayaan Zaidi <[email protected]>
## Result A member who sends on the `global` session gets a reply again. Since #204219, the reply turn could end with `status: error, stopReason: "rpc"` and the message "OpenClaw couldn't finish this reply", and no assistant entry was written. This happened even with `agents.defaults.promptCacheKeepWarm: false`. ## Cause #204219 added a committed-facts listener in `src/cron/maintenance.ts` that calls `notePromptCacheKeepWarmChange` for every transcript change. That function resolved the agent with `resolveAgentIdFromSessionKey(sessionKey)`. Transcript receipts (`publishCommittedSessionTranscriptReceipts`) name no `agentId`, and for the `global` key that resolver **throws** ("Session key does not contain an agent id"). The listener runs inside committed-fact installation (`sessionChanges.emitBatch` → `publishSqliteCommittedState`). A throw there fails the batch, and the publication's `invalidate()` sends every fact listener a copy of the change with `factsInvalidated: true`. The member turn's retained session-sharing facts (`prepareSessionMutationFacts`, followed by `chat.send`) treat that as a foreign change and invalidate themselves. The next `assertTargetCurrent` then throws `SessionMutationAuthorizationChangedError: session changed before chat.send`, and the run settles as a failure. The listener is registered whether keep-warm is on or off. That is why the switch did not help. Trace (runtime probes, removed): run error → `agent-runner-error-handler` `SessionMutationAuthorizationChangedError` → `readCurrent` saw `SessionMutationFactsUnavailableError` → facts `invalidate()` on `{ sessionKey: "global", scope: "transcript", factsInvalidated: true }` → `sqlite-post-commit` `invalidate` ← `publishCommittedSessionTranscriptReceipts`. Calling `notePromptCacheKeepWarmChange` directly with `global` throws. ## Fix `notePromptCacheKeepWarmChange` returns without a candidate when the change names no agent and the key is not an agent key. It no longer throws inside fact installation. Agent keys (`agent:<id>:…`) and changes that carry `agentId` behave as before. Accepted edge case: a `global` or legacy-key transcript receipt without an `agentId` does not schedule a keep-warm ping. Before this fix, such a receipt failed the commit instead. ## Evidence - `src/gateway/server.chat-membership-authority.product.test.ts`: fails on `b36ba3fe` (#204219; the parent `2264fd00` passes), passes on this head. The test starts a real Gateway server on a scratch port with a TLS WebSocket and a trusted-proxy member identity, and sends to a provider HTTP server. A member's `chat.send` and `agent` turns on `global` for both agents now get replies. - New `src/cron/maintenance-lifecycle.test.ts` case: a `global` transcript change installs once, with no `factsInvalidated` re-delivery. It fails on `b36ba3fe` (3 deliveries) and passes on the head. - #204219's keep-warm tests still pass: `prompt-cache-keep-warm.test.ts`, `maintenance-lifecycle.test.ts` ("wakes keep-warm … when an interactive session's transcript settles"), `session-fork-request.test.ts`, `cache-ttl.test.ts`, `openai-prompt-cache.test.ts`, `anthropic-transport-stream.prewarm.test.ts`. - Gap: I did not repeat #204219's paid provider prewarm probes. This change touches only candidate noting for agent-less non-agent keys, and that path never produced a ping. - CI: the only reds also fail on `main` or in unrelated PRs (see the Maintainer override comment). Local ClawSweeper: patch is correct, no findings. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 6312567) Co-authored-by: RomneyDa <[email protected]>
Result
A member who sends on the
globalsession gets a reply again. Since #204219, the reply turn could end withstatus: error, stopReason: "rpc"and the message "OpenClaw couldn't finish this reply", and no assistant entry was written. This happened even withagents.defaults.promptCacheKeepWarm: false.Cause
#204219 added a committed-facts listener in
src/cron/maintenance.tsthat callsnotePromptCacheKeepWarmChangefor every transcript change. That function resolved the agent withresolveAgentIdFromSessionKey(sessionKey). Transcript receipts (publishCommittedSessionTranscriptReceipts) name noagentId, and for theglobalkey that resolver throws ("Session key does not contain an agent id").The listener runs inside committed-fact installation (
sessionChanges.emitBatch→publishSqliteCommittedState). A throw there fails the batch, and the publication'sinvalidate()sends every fact listener a copy of the change withfactsInvalidated: true. The member turn's retained session-sharing facts (prepareSessionMutationFacts, followed bychat.send) treat that as a foreign change and invalidate themselves. The nextassertTargetCurrentthen throwsSessionMutationAuthorizationChangedError: session changed before chat.send, and the run settles as a failure.The listener is registered whether keep-warm is on or off. That is why the switch did not help.
Trace (runtime probes, removed): run error →
agent-runner-error-handlerSessionMutationAuthorizationChangedError→readCurrentsawSessionMutationFactsUnavailableError→ factsinvalidate()on{ sessionKey: "global", scope: "transcript", factsInvalidated: true }→sqlite-post-commitinvalidate←publishCommittedSessionTranscriptReceipts. CallingnotePromptCacheKeepWarmChangedirectly withglobalthrows.Fix
notePromptCacheKeepWarmChangereturns without a candidate when the change names no agent and the key is not an agent key. It no longer throws inside fact installation. Agent keys (agent:<id>:…) and changes that carryagentIdbehave as before.Accepted edge case: a
globalor legacy-key transcript receipt without anagentIddoes not schedule a keep-warm ping. Before this fix, such a receipt failed the commit instead.Evidence
src/gateway/server.chat-membership-authority.product.test.ts: fails onb36ba3fe(feat(agents): keep idle prompt caches warm with read-only prewarms #204219; the parent2264fd00passes), passes on this head. The test starts a real Gateway server on a scratch port with a TLS WebSocket and a trusted-proxy member identity, and sends to a provider HTTP server. A member'schat.sendandagentturns onglobalfor both agents now get replies.src/cron/maintenance-lifecycle.test.tscase: aglobaltranscript change installs once, with nofactsInvalidatedre-delivery. It fails onb36ba3fe(3 deliveries) and passes on the head.prompt-cache-keep-warm.test.ts,maintenance-lifecycle.test.ts("wakes keep-warm … when an interactive session's transcript settles"),session-fork-request.test.ts,cache-ttl.test.ts,openai-prompt-cache.test.ts,anthropic-transport-stream.prewarm.test.ts.