Skip to content

fix(agents): a member on the global session gets a reply again - #204335

Merged
obviyus merged 1 commit into
mainfrom
fix/membership-reply-rpc-stop
Nov 24, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/membership-reply-rpc-stop

Conversation

@obviyus

@obviyus obviyus commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

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 (feat(agents): keep idle prompt caches warm with read-only prewarms #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.
  • feat(agents): keep idle prompt caches warm with read-only prewarms #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 feat(agents): keep idle prompt caches warm with read-only prewarms #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.

…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]>
@clawsweeper

clawsweeper Bot commented Nov 24, 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 agents Agent runtime and tooling size: XS labels Nov 24, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 24, 2026
@clawsweeper

clawsweeper Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Keep-warm bookkeeping throws during transcript fact installation, and the reply can end with stopReason "rpc" without a stored assistant reply.
  • After: The agent-less receipt skips keep-warm bookkeeping, allowing transcript facts and the member's reply to complete.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with useful Gateway integration coverage; supplied execution remains harness-based and exact-head CI has an unattributed failure.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the contributor proof gate; its supplied validation exercises member turns through a real Gateway with a fixture provider, rather than a real model deployment.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Members sending to a global session can receive a failed reply instead of an assistant response.
Reason: The maintainer-authored direction restores documented global-session behavior, and every introduced hunk serves that repair.

Regression provenance

Possible 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
Reviewed head: f980b81d932572d6c71623491fa65c664654fae5

Before merge

None.

Findings

None.

Agent review details

How this fits together

Cron 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]
Loading

Technical review

Best 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

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit b36ba3f adds src/agents/prompt-cache-keep-warm-candidates.ts:72 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b36ba3fed244; files: src/agents/prompt-cache-keep-warm-candidates.ts)
  • Josh Avant: Raw commit ea9abff adds src/cron/maintenance-lifecycle.test.ts:97 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: ea9abff9e8dc; files: src/cron/maintenance-lifecycle.test.ts)
  • Peter Steinberger: Raw commit 6d249d2 adds src/cron/maintenance-lifecycle.test.ts:103 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 6d249d2fe52e; files: src/cron/maintenance-lifecycle.test.ts)

PR surface

Source +5, Tests +21. Total +26 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 6 1 +5
Tests 1 21 0 +21
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 27 1 +26

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P1: The reported and source-supported regression prevents members from receiving replies in supported global sessions, including with keep-warm disabled.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: The reported and source-supported regression prevents members from receiving replies in supported global sessions, including with keep-warm disabled.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve whether the failed announcement-settlement check is introduced or inherited before landing.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 23, 2026, 9:24 PM ET / November 24, 2026, 02:24 UTC.

@obviyus

obviyus commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

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 src/agents/, the PR plan from #204292 selected the wide e2e set.

Check File Evidence that it is not caused by this PR
checks-node-changed-1 test/e2e/qa-lab/runtime/channel-progress-presentation.e2e.test.ts Same 2 cases fail locally on main 7cbf158 without this change
checks-node-changed-8/9/10/12/13/15/17 cron-forced-after-turn, bash-tools.exec-gateway-approval, gateway-skill-authoring-plugin, server-templates-add-authority, gateway-plugin-turn-handover, gateway-cold-agent-abort, gateway-restart-resume, gateway-yield-restart, prompt-cache-prefix-stability.google (e2e) All 9 files fail locally on main 7cbf158 (18 failed, 13 passed). The same files fail in unrelated PR runs 45313132755, 45313513020 and 45315096872
checks-node-changed-compact-large-2 / large-31-1 agent-runner-required-maintenance.pending-input, session-context-accounting.gateway.integration ci-triage: MAIN-ALSO (known #204111/#204180 reds, owned separately)

The test this PR fixes, server.chat-membership-authority.product.test.ts, passes on the head. Local ClawSweeper: patch is correct.

@obviyus
obviyus merged commit 6312567 into main Nov 24, 2026
167 of 179 checks passed
@obviyus
obviyus deleted the fix/membership-reply-rpc-stop branch November 24, 2026 03:09
@obviyus

obviyus commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 6312567. Since #204219, keep-warm candidate noting threw for transcript receipts on the global session, which name no agent. The throw happened inside committed-fact installation. That invalidated the member's retained session facts, so their turn ended as 'couldn't finish this reply'. The guard now skips agent-less, non-agent keys. Proof: the membership product test fails on b36ba3f and passes on the head, and a new maintenance test covers the global case.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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