agents-0-21-0-16-b
Claude Code's read-only tools, web search on, ludion sync on
Question
Which function traces AI SDK v7 calls in the Cloudflare agents package?
Answer key
- A correct answer says
- `wrapAISDK()` from `agents/observability/ai` is the only AI SDK tracing integration for both v6 and v7; `createAISDKTelemetry()` was removed.
- The stale answer
- Use `createAISDKTelemetry()` for AI SDK v7 tracing and `wrapAISDK` for v6.
Answer
The function is `wrapAISDK`, imported from `agents/observability/ai`. You pass it the AI SDK namespace and it returns the same namespace with tracing added (for example, `const ai = wrapAISDK(await import("ai"))`). It works with AI SDK v6 and v7. Its optional second argument, `AISDKInstrumentationOptions`, has three settings: `storeMessages` and `storeTools`, which both default to `false`, and `includeRuntimeContext`, which picks the context keys to record as `cloudflare.agents.runtime_context.*` attributes. The declaration is in `node_modules/agents/dist/observability/ai/index.d.ts:24` in the installed agents 0.27.0.Grade
correct
The judge's reason: It names wrapAISDK() from agents/observability/ai as supporting both v6 and v7 and does not present createAISDKTelemetry() as current.
Session log
Tool call: Grep
{ "pattern": "(?i)trac(e|ing)\\w*\\s*\\(", "path": "C:\\Users\\haya0\\AppData\\Local\\Temp\\ludion-bench-Nbgu27\\work\\node_modules\\agents", "glob": "*.d.ts", "output_mode": "content", "head_limit": 30 }Tool output
No matches foundTool call: Grep
{ "pattern": "(?i)ai sdk|ai-sdk|trac(e|ing)", "path": "C:\\Users\\haya0\\AppData\\Local\\Temp\\ludion-bench-Nbgu27\\work\\node_modules\\agents", "output_mode": "files_with_matches", "head_limit": 40 }Tool output
Found 40 files limit: 40 node_modules\agents\dist\ws-chat-transport-BbT1A5Lc.d.ts node_modules\agents\dist\types-B7LojTe4.d.ts node_modules\agents\dist\types-_Faxb570.d.ts node_modules\agents\dist\transport-k2mFrtL8.d.ts node_modules\agents\dist\browser\tanstack-ai.d.ts node_modules\agents\dist\settings-NgGwF7Qt.d.ts node_modules\agents\dist\sentence-chunker-BAidJ4DA.d.ts node_modules\agents\dist\chat\react.d.ts node_modules\agents\dist\schedules\parser.d.ts node_modules\agents\dist\observability\ai\index.d.ts node_modules\agents\dist\models\pi-ai\index.d.ts node_modules\agents\dist\models\opencode\index.d.ts node_modules\agents\dist\models\ai-sdk\index.d.ts node_modules\agents\dist\harness\think\index.d.ts node_modules\agents\dist\harness\ai-sdk\index.d.ts node_modules\agents\dist\chat\index.d.ts node_modules\agents\dist\client-tools-aIBO0Fk7.d.ts node_modules\agents\dist\capability-runner-O5VbQzqg.d.ts node_modules\agents\dist\browser\ai.d.ts node_modules\agents\dist\websearch\tools\ai-sdk.d.ts node_modules\agents\dist\experimental\channels\web\ai-sdk.d.ts node_modules\agents\dist\browser\ai-sdk.d.ts node_modules\agents\dist\agent-tools.d.ts node_modules\agents\dist\agent-routing-Bhdbvf7s.d.ts node_modules\agents\docs\harnesses\think.md node_modules\agents\docs\sessions.md node_modules\agents\docs\server-driven-messages.md node_modules\agents\docs\search-the-web.md node_modules\agents\docs\scheduling.md node_modules\agents\README.md node_modules\agents\docs\observability.md node_modules\agents\docs\models.md node_modules\agents\docs\models-pi-ai.md node_modules\agents\docs\migration-to-ai-sdk-v6.md node_modules\agents\docs\migration-to-ai-sdk-v5.md node_modules\agents\docs\mcp-servers.md node_modules\agents\docs\mcp-client.md node_modules\agents\docs\index.md node_modules\agents\docs\human-in-the-loop.md node_modules\agents\docs\get-current-agent.mdTool call: Glob
{ "pattern": "node_modules/agents/*" }Tool output
node_modules\agents\agents.tsconfig.json node_modules\agents\package.json node_modules\agents\README.md node_modules\agents\skills-module.d.ts node_modules\agents\LICENSETool call: Read
{ "file_path": "C:\\Users\\haya0\\AppData\\Local\\Temp\\ludion-bench-Nbgu27\\work\\node_modules\\agents\\dist\\observability\\ai\\index.d.ts" }Tool output
1 //#region src/observability/ai/options.d.ts 2 /** Opt-in span payload storage. Both flags default to `false`. */ 3 type AISDKStorageOptions = { 4 readonly storeMessages?: boolean; 5 readonly storeTools?: boolean; 6 }; 7 /** Instrumentation options for the AI SDK v6 and v7 wrapper. */ 8 type AISDKInstrumentationOptions = AISDKStorageOptions & { 9 /** 10 * Context keys to emit as `cloudflare.agents.runtime_context.{key}`, set 11 * once for the wrapper rather than per call. 12 * 13 * Distinct from the AI SDK's own per-call `telemetry.includeRuntimeContext`, 14 * which shares the name but selects keys that map onto the canonical 15 * `cloudflare.agents.turn.*` / `cloudflare.agents.metadata.*` attributes. 16 */ 17 readonly includeRuntimeContext?: readonly string[]; 18 }; 19 //#endregion 20 //#region src/observability/ai/index.d.ts 21 /** 22 * Wraps an AI SDK namespace with tracing. 23 */ 24 declare function wrapAISDK<T extends Record<string, unknown>>( 25 ai: T, 26 options?: AISDKInstrumentationOptions 27 ): T; 28 //#endregion 29 export { 30 type AISDKInstrumentationOptions, 31 type AISDKStorageOptions, 32 wrapAISDK 33 }; 34 //# sourceMappingURL=index.d.ts.map 35Tool call: Grep
{ "pattern": "observability/ai", "path": "C:\\Users\\haya0\\AppData\\Local\\Temp\\ludion-bench-Nbgu27\\work\\node_modules\\agents\\package.json", "output_mode": "content" }Tool output
275: "./observability/ai": { 276: "types": "./dist/observability/ai/index.d.ts", 277: "import": "./dist/observability/ai/index.js", 278: "require": "./dist/observability/ai/index.js"Agent
The function is `wrapAISDK`, imported from `agents/observability/ai`. You pass it the AI SDK namespace and it returns the same namespace with tracing added (for example, `const ai = wrapAISDK(await import("ai"))`). It works with AI SDK v6 and v7. Its optional second argument, `AISDKInstrumentationOptions`, has three settings: `storeMessages` and `storeTools`, which both default to `false`, and `includeRuntimeContext`, which picks the context keys to record as `cloudflare.agents.runtime_context.*` attributes. The declaration is in `node_modules/agents/dist/observability/ai/index.d.ts:24` in the installed agents 0.27.0.