Skip to content

fix(gateway): gate session.tool mirrors behind session subscriptions - #124732

Merged
steipete merged 1 commit into
mainfrom
codex/autoqa-session-tool-gate
Aug 16, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/autoqa-session-tool-gate

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

session.tool mirrors the raw agent tool event — full tool args and result snapshots — onto session subscribers so operator UIs attaching mid-run can render live tool cards. But the event name was missing from SESSION_SUBSCRIPTION_EVENTS, the allowlist that scopes session-bearing broadcasts for clients with the session-scoped-events cap (and browser copilot clients). A scoped client subscribed to one session's messages therefore received every session's tool payloads through the mirror — the exact data the registry gate correctly suppresses on the raw agent event. The gate's own comment promises "opt-in scoped clients never receive session-bearing broadcasts without an authoritative registry key"; session.observer was added to the set for precisely this mirror-event class, and session.tool carries strictly more data.

Why This Change Was Made

Root cause: the gate is an allowlist and the newer mirror event never joined it. The fix is one set entry with an invariant comment. The payload already carries sessionKey (server-chat spreads it into agentPayload), so resolveBroadcastSessionScope keys the registry check without any producer change, and unscoped Control UI clients keep full fanout per the existing design.

User Impact

Session-scoped clients (browser copilot, cap-gated integrations) no longer see tool arguments and results from sessions they did not subscribe to. No change for regular Control UI clients.

Evidence

  • New regression in src/gateway/server-broadcast.board.test.ts drives the server-chat-style targeted session.tool fanout: scoped client subscribed to the same session receives it, scoped client on a different session receives nothing, unscoped client keeps full fanout — fails pre-fix (cross-session leak).
  • node scripts/run-vitest.mjs run src/gateway/server-broadcast.board.test.ts src/gateway/server-chat.agent-events.test.ts — 161 tests pass.
  • tsgo core + core-test shards, oxfmt, oxlint clean.
  • Codex autoreview: clean, 0.99 ("patch is correct").
  • LOC: prod +4 −0 (set entry + comment), test +32.

session.tool mirrors the raw agent tool event (full args/result
snapshots) onto session subscribers, but the event name was missing from
SESSION_SUBSCRIPTION_EVENTS. Clients with the session-scoped-events cap
(or browser copilot) that subscribed to one session's messages therefore
received every session's tool payloads through the mirror — the exact
data the registry gate suppresses on the raw agent event. session.observer
was added to the set for precisely this mirror-event class; session.tool
carries strictly more data.

Root cause: the gate is an allowlist and the newer mirror event never
joined it. One set entry; the payload already carries sessionKey so
registry keying works unchanged, and unscoped Control UI clients keep
full fanout.

Regression: new board test drives the server-chat-style targeted fanout
and asserts a scoped client subscribed to a different session receives
nothing — fails pre-fix.
@clawsweeper

clawsweeper Bot commented Aug 16, 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: XS maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 18:22
@steipete
steipete merged commit 1bcec21 into main Aug 16, 2026
277 checks passed
@steipete
steipete deleted the codex/autoqa-session-tool-gate branch August 16, 2026 18:30
@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 17, 2026
…penclaw#124732)

session.tool mirrors the raw agent tool event (full args/result
snapshots) onto session subscribers, but the event name was missing from
SESSION_SUBSCRIPTION_EVENTS. Clients with the session-scoped-events cap
(or browser copilot) that subscribed to one session's messages therefore
received every session's tool payloads through the mirror — the exact
data the registry gate suppresses on the raw agent event. session.observer
was added to the set for precisely this mirror-event class; session.tool
carries strictly more data.

Root cause: the gate is an allowlist and the newer mirror event never
joined it. One set entry; the payload already carries sessionKey so
registry keying works unchanged, and unscoped Control UI clients keep
full fanout.

Regression: new board test drives the server-chat-style targeted fanout
and asserts a scoped client subscribed to a different session receives
nothing — fails pre-fix.
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 size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant