← Back to PRs

#8352: fix(gateway): include clientRunId in agent event payloads

by MarvinDontPanic open 2026-02-03 22:32 View on GitHub →
gateway stale
## Problem Agent event payloads broadcast via WebSocket don't include `clientRunId` when it differs from the internal `runId`. This causes frontends to potentially drop or misroute events in scenarios where IDs diverge (e.g., isolated sub-agent sessions via `sessions_spawn`). ## Solution Include `clientRunId` in the broadcast payload when present and different from `runId`. This is a no-op for typical webchat sessions where IDs match, but enables correct event routing for spawned sessions. ## Changes - 8 lines in `src/gateway/server-chat.ts` ## Testing Verified with sub-agent spawning — events now correctly correlate to the originating session. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> Updates the gateway’s agent-event broadcast payload construction to include `clientRunId` (when it differs from `evt.runId`) alongside the existing `sessionKey`. This allows web frontends to correctly correlate events for spawned/isolated sub-agent sessions where the internal run ID and the client-facing run ID diverge, while remaining a no-op for typical sessions where IDs match. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - Change is small, localized to payload shaping, and guarded so `clientRunId` is only added when present and different from `runId`; existing behavior is unchanged for normal sessions. No type/logic hazards were identified in the modified code path. - No files require special attention <!-- greptile_other_comments_section --> <sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs