Skip to content

fix(gateway): live sessions stall or reorder across agent identities - #128265

Merged
steipete merged 2 commits into
mainfrom
codex/autoqa-gateway-agent-transcript-lanes-20260823
Aug 23, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/autoqa-gateway-agent-transcript-lanes-20260823

Conversation

@steipete

@steipete steipete commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators viewing multiple agents could see one agent's live global session stop updating while another agent waited for transcript projection. The same session could also display messages out of order when successive updates used its bare global key and its agent-qualified alias, or when a marker-only SQLite transcript update was followed by its canonical session key.

Why This Change Was Made

Gateway transcript broadcasting already promises one ordered lane per transcript, but it keyed lanes by the raw session string instead of the transcript's agent-qualified identity. Reuse the existing canonical session subscription key and resolve ownership at the transcript producer boundary, preserving explicit agent ownership, legacy SQLite markers, configured fixed-store owners, compatibility defaults, unresolved legacy events, and existing same-session ordering. Resolve marker-only updates to their authoritative persisted session key before assigning the queue so they share the canonical transcript's lane.

User Impact

Different agents' live session updates no longer block one another, while messages for the same session remain correctly ordered across legacy and agent-qualified names. No public API, protocol, configuration, authentication, security, or storage contract changes.

Evidence

  • Exact reviewed head: 936b3d15b2b3c278b95f534244e3c1d0d32686af.
  • Before: three genuine owner-boundary regressions failed in both Gateway test projects: cross-agent global delivery stalled, a same-agent qualified alias delivered the second message first, and a later canonical update overtook an in-flight marker-only SQLite transcript update.
  • After: node scripts/run-vitest.mjs src/gateway/server-session-events.test.ts src/gateway/server-runtime-subscriptions.test.ts src/gateway/server-node-subscriptions.test.ts src/gateway/server.node-chat-subscriptions.test.ts src/gateway/server-chat.agent-events.test.ts --configLoader runner --experimental.fsModuleCachePath /private/tmp/openclaw-autoqa-gateway-agent-vitest-correction-cache passed 428 tests, including real isolated localhost WebSocket delivery.
  • node scripts/run-vitest.mjs src/sessions/transcript-events.test.ts --configLoader runner --experimental.fsModuleCachePath /private/tmp/openclaw-autoqa-gateway-agent-vitest-unit-cache passed 21 producer tests.
  • Real SQLite-backed Gateway integration passed 2 marker-delivery tests; renewed independent review separately passed 89 owner, producer, and live marker-integration tests and reported no actionable findings. Fresh authenticated correction review also reported no actionable findings.
  • The ClawSweeper marker-only queue-lane finding and both rank-up moves are addressed at the existing authoritative transcript producer boundary and covered by an authentic failing-before/passing-after regression.
  • Core production and Gateway test typechecks, scoped lint, formatting, and git diff --check passed.
  • Production delta: +20 lines, required to preserve canonical explicit, marker-only, fixed-store, and compatibility owner identities without changing the public protocol; test delta: +85 lines.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 23, 2026
@steipete
steipete marked this pull request as ready for review August 23, 2026 16:04
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 1:02 PM ET / 17:02 UTC.

ClawSweeper review

What this changes

The PR canonicalizes live transcript queue keys by agent and persisted session identity so cross-agent global sessions do not stall each other and aliases or SQLite markers for one transcript remain ordered.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main still keys transcript lanes by raw session strings or file markers, while this head canonicalizes agent identity before queueing; the prior marker-order finding is addressed and no blocking correctness defect was found.

Priority: P1
Reviewed head: 936b3d15b2b3c278b95f534244e3c1d0d32686af

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused real transport and SQLite evidence, plus owner-boundary regressions, support a normal good-quality rating with no blocking finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body records after-fix isolated localhost WebSocket delivery and SQLite-backed Gateway integration for this internal reliability change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body records after-fix isolated localhost WebSocket delivery and SQLite-backed Gateway integration for this internal reliability change.
Evidence reviewed 6 items Current-main defect: Current main selects the queue lane from the raw target key, supplied key, or session file, so different agents using bare global collide and marker-only updates do not share their canonical session lane.
Canonical repair at queue boundary: The head resolves marker-backed keys and agent ownership before selecting the queue lane, then reuses the existing subscription-key canonicalizer.
Producer and storage contract: SQLite-backed transcript writes already emit a complete canonical target; marker-only events can authoritatively resolve their persisted session key through the session-id primary-key lookup.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/gateway/server-session-events.test.ts --configLoader runner

Result: FAIL (partial) — step 2 expect_output preserves message order for a marker-only update and its canonical transcript key: expected terminal output was not visible within 30 seconds: "preserves message order for a marker-only update and its canonical transcript key"

node scripts/run-vitest.mjs src/gateway/server-session-events.test.ts --configLoader runner
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128265-u0AmBI/target$ node scripts/run-vitest.mjs src/gateway/server-session-events.test.ts --configLoader runn
er
node scripts/run-vitest.mjs src/gateway/server-session-events.test.ts --configLoader runner
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128265-u0AmBI/target

 ✓  gateway-server-isolated  ../../src/gateway/server-session-events.test.ts (33 tests) 692ms
 ✓  gateway-server  ../../src/gateway/server-session-events.test.ts (33 tests) 712ms

 Test Files  2 passed (2)
      Tests  66 passed (66)
   Start at  17:03:06
   Duration  12.31s (transform 8.45s, setup 682ms, import 9.91s, tests 1.40s, environment 0ms)

[test] passed 1 Vitest shard in 17.11s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128265-u0AmBI/target$ node scripts/run-vitest.mjs src/gateway/server-session-events.test.ts --configLoader runn
er
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128265-u0AmBI/target

 ✓  gateway-server-isolated  ../../src/gateway/server-session-events.test.ts (33 tests) 684ms
 ✓  gateway-server  ../../src/gateway/server-session-events.test.ts (33 tests) 705ms

 Test Files  2 passed (2)
      Tests  66 passed (66)
   Start at  17:03:23
   Duration  6.47s (transform 2.64s, setup 334ms, import 4.45s, tests 1.39s, environment 0ms)

[test] passed 1 Vitest shard in 11.25s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128265-u0AmBI/target$


















Assertions:

  • FAIL expect_output: preserves message order for a marker-only update and its canonical transcript key

How this fits together

Gateway receives internal transcript-update events after session storage changes and projects them to subscribed operator clients. Its per-transcript queue serializes updates before session-message and session-change events are sent over WebSockets.

flowchart LR
  A[Transcript write] --> B[Internal update event]
  B --> C[Canonical session identity]
  C --> D[Per-transcript queue]
  D --> E[Gateway projection]
  E --> F[Operator WebSocket clients]
Loading

Before merge

  • Resolve merge risk (P1) - This is a +20-line production change in live delivery ordering; an incorrect identity equivalence could still serialize unrelated sessions together or split one transcript’s lane, so exact-head delivery checks must finish before merge.
  • Complete next step (P2) - This protected maintainer PR has no remaining mechanical repair; it needs normal exact-head CI completion and maintainer merge handling.
Agent review details

Security

None.

PR surface

Source +20, Tests +85. Total +105 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 24 4 +20
Tests 1 113 28 +85
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 137 32 +105

Review metrics

Metric Value Why it matters
Production versus regression coverage production +20, tests +85 The added production logic canonicalizes queue identity before asynchronous dispatch; the tests cover the affected global, alias, marker, and fixed-owner combinations.

Merge-risk options

Maintainer options:

  1. Finish exact-head delivery validation (recommended)
    Merge after the pending checks confirm the canonical lane behavior on this exact head, including message ordering and session projection.

Technical review

Best possible solution:

Keep one canonical queue identity derived before the first asynchronous transcript read, retain the focused ordering regressions, and merge only after exact-head checks validate the delivery surface.

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

Yes: current main’s raw lane selection is source-proven, and the focused handler cases provide a high-confidence reproduction path for cross-agent global and marker/canonical ordering; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes: canonicalizing identity before queue selection is the narrowest fix because later projection cannot restore ordering once two updates entered different lanes.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 917fab24a50d.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body records after-fix isolated localhost WebSocket delivery and SQLite-backed Gateway integration for this internal reliability change.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The change repairs live transcript delivery and ordering across active agent sessions.
  • merge-risk: 🚨 message-delivery: Queue-key normalization directly controls whether live transcript messages stall or retain order.
  • merge-risk: 🚨 session-state: The queue now associates updates with agent-qualified transcript identity, affecting how live session state is sequenced.
  • 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 (terminal): The PR body records after-fix isolated localhost WebSocket delivery and SQLite-backed Gateway integration for this internal reliability change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body records after-fix isolated localhost WebSocket delivery and SQLite-backed Gateway integration for this internal reliability change.

Evidence

What I checked:

Likely related people:

  • steipete: Historical commits establish the per-transcript lane and scoped-global delivery behavior, and this PR continues that same queue-identity work. (role: feature owner and recent area contributor; confidence: high; commits: ad1a2cd7e73a, 2f97e8c9ebdc; files: src/gateway/server-session-events.ts, src/gateway/session-subscription-keys.ts)

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 (1 earlier review cycle)
  • reviewed 2026-08-23T16:09:32.984Z sha dfdcb7d :: needs changes before merge. :: [P1] Resolve marker-only updates to their canonical queue lane

@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 Aug 23, 2026
@steipete
steipete merged commit b0dafb2 into main Aug 23, 2026
239 checks passed
@steipete
steipete deleted the codex/autoqa-gateway-agent-transcript-lanes-20260823 branch August 23, 2026 17:26
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
…penclaw#128265)

* fix(gateway): isolate transcript lanes by agent identity

* fix(gateway): order marker-only transcript updates correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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