Repository navigation
feat(cloud-workers): replayable worker live-event streaming into the session fanout - #105275
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 968e6afead
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const hasProjectedRun = hasProjectedAgentRunForSession({ | ||
| sessionKeys: [params.requestedKey, params.canonicalKey], | ||
| ...(sessionId ? { sessionId } : {}), | ||
| }); |
There was a problem hiding this comment.
Keep projected active runs scoped to the requested agent
When the selected session is global, callers pass agentId/defaultAgentId so active-run checks don't leak across agents, but this new projected-run path only checks sessionKeys/sessionId. A hidden worker run registered for another agent's global session can therefore make sessions.list or chat.info for the requested agent report hasActiveRun: true with no abortable runIds; pass the agent scope through and compare it like isTrackedActiveSessionRunForKey does.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed July 12, 2026, 8:44 AM ET / 12:44 UTC. Summary PR surface: Source +1890, Tests +1030, Docs 0. Total +2920 across 33 files. Reproducibility: yes. at source level. The deterministic paths are a cross-agent Review metrics: 2 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Preserve the existing single fanout architecture, but pass agent scope into projected-run matching and retain already-emitted claims until queued gateway projection has settled; add exact regression tests for both paths and attach redacted final-head live reconnect/replay evidence before merge. Do we have a high-confidence way to reproduce the issue? Yes at source level. The deterministic paths are a cross-agent Is this the best way to solve the issue? No on the current head. Reusing the existing fanout is the narrow maintainable architecture, but the implementation does not yet preserve its established agent-scoping and event-ownership lifetime invariants. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 42d34eb4c8b5. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +1890, Tests +1030, Docs 0. Total +2920 across 33 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (3 earlier review cycles)
|
968e6af to
2119dd5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2119dd51bd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| if (failed.details.reason === "capacity-exceeded" && !publishedPrefix) { | ||
| // A fresh head cannot advance. Reset its cursor and release every claim. | ||
| clearWindow(window); |
There was a problem hiding this comment.
Keep ACKed live claims until queued projections run
When a new head event hits capacity-exceeded, this immediately clearWindow()s and releases every existing claim, including prior events that were already ACKed. Gateway fanout is deferred through dispatchEventHandler() in src/gateway/server-runtime-subscriptions.ts, and createAgentEventHandler() drops owned events once getAgentRunContextOwnerStatus() is no longer active; so if a worker sends a second run before the async handler processes the first ACKed live event, the first event can be silently lost from session subscribers. Defer releasing existing claims until the in-flight projection has settled, or avoid gating already-emitted events on a claim that this reset releases.
Useful? React with 👍 / 👎.
2119dd5 to
d7ee851
Compare
|
Merged via squash.
|
…session fanout (openclaw#105275) * feat(protocol): add worker live-event frames * feat(gateway): fan out replayable worker live events * feat(gateway): add worker live-event replay receiver * docs(protocol): document worker live events * fix(gateway): preserve deferred worker live events * test(gateway): cover deferred worker event projection * refactor(gateway): revert async projection layer * fix(gateway): retain buffered worker live events * fix(gateway): guard buffered terminal admission * fix(plugin-sdk): trim worker live-event declarations
Part of #104294 (cloud workers, milestone 2, PR 7). Builds on #104688 (worker role) and #104809 (transcript commits). Design:
docs/plan/cloud-workers.md("Session backend RPCs" — replayable live events; anddocs/concepts/streaming.md).What Problem This Solves
Transcript commits (PR 6) make a worker session's durable messages appear in the sidebar, but only at turn boundaries. This PR adds the ephemeral, replayable live-event channel so a worker session streams in real time — token deltas, tool start/finish, approvals, run-status — by translating each worker event into the SAME internal agent event and pushing it through the EXISTING fanout, so chat view / tool rows / unread-status behave identically to a local session. No parallel streaming path, no token-delta channel message (per streaming.md). Durable content still arrives via the PR-6 commit path; the live channel never writes transcript entries.
Why This Change Was Made
emitAgentEventForOwnerinto the normal fanout.Deep-review findings fixed pre-merge
A dedicated deep code review (verified independently) found and fixed:
Promise.allSettled), while detach/supersession teardown stays immediate. Proven by a new gateway+WebSocket integration test asserting exactly-once delivery of a published prefix across a subsequent buffered-capacity event.pendingstate cleared on in-window resync (prevents a stale buffered event shadowing a renumbered one).resolveOrCreateWindow) and removed a dead epoch branch.User Impact
Opt-in only; the worker loop that drives these events lands in PR 9. This is the real-time streaming mechanism for worker sessions. No config/changelog/version-bump changes.
Evidence