Patch Changes
-
#930
cd408feThanks @threepointone! - Fix stale agent reference in useAgentChat transport under React StrictModeThe
agentRefwas updated viauseEffect(async, after render), but theWebSocketChatTransportis created inuseMemo(sync, during render). When the agent reconnects or switches,useMemowould capture the old (closed) agent because the effect hadn't fired yet — causingsendMessageto send to a dead WebSocket. Fixed by updatingagentRef.currentsynchronously during render, matching the pattern already used by other refs in the same hook.