instrumentOpenAIAgents
โธ instrumentOpenAIAgents():Promise<boolean>
Manually register Weave tracing with OpenAI Agents if the package is available.
Note: You typically donโt need to call this function! OpenAI Agents 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).
This function attempts to dynamically import @openai/agents from the consumerโs node_modules
and registers a TracingProcessor. If the package is not installed, it returns false without
throwing an error.
Returns
Promise<boolean>
Promise<boolean> - true if registration succeeded, false if @openai/agents not available
Example
Example
Remarks
How automatic instrumentation works: When you import Weave, it registers module loader
hooks via addCJSInstrumentation() and addESMInstrumentation(). When your code later
imports @openai/agents, these hooks intercept the import and automatically patch the
module to add Weave tracing. This happens transparently - no action required from you!
When to use this function: Only use this if automatic instrumentation fails, such as:
- Using dynamic imports that bypass module hooks
- Bundlers that donโt support import-in-the-middle
- Need explicit control over when instrumentation happens
createOpenAIAgentsTracingProcessor() and register it manually: