Skip to main content

patchRealtimeSession

โ–ธ patchRealtimeSession(): Promise<boolean> Manually patch the RealtimeSession class from @openai/agents-realtime so that every new instance is automatically traced by Weave. Note: You typically donโ€™t need to call this function! @openai/agents-realtime is automatically instrumented via module loader hooks when you import Weave. This function is provided for edge cases where automatic instrumentation doesnโ€™t work (e.g. dynamic imports, bundlers that bypass hooks). Call this once at app startup, before any RealtimeSession is constructed. The function is idempotent โ€” safe to call multiple times.

Returns

Promise<boolean> true if the patch was applied (or was already in place), false if @openai/agents-realtime could not be loaded. Example
import { patchRealtimeSession } from 'weave';
await patchRealtimeSession();
// Every new RealtimeSession(...) is now auto-instrumented

Defined in

integrations/openai.realtime.agent.ts:808