agents-0-21-0-16-b
Claude Code's read-only tools, web search on, ludion sync off
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`**, exported from `agents/observability/ai` (`node_modules/agents/dist/observability/ai/index.d.ts:24`). You pass it the AI SDK namespace, for example `wrapAISDK(ai, options)`, and it returns the same namespace with tracing added. It works with both AI SDK v6 and v7. Its optional `AISDKInstrumentationOptions` are `storeMessages` and `storeTools`, which both default to `false`, and `includeRuntimeContext`, which emits the context keys you list as `cloudflare.agents.runtime_context.{key}` attributes.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": "v7|ai-sdk|aisdk", "-i": true, "head_limit": 30 }Tool output
Found 30 files limit: 30 node_modules\.package-lock.json package-lock.json node_modules\zod\v4\mini\schemas.js node_modules\zod\v4\mini\schemas.d.ts node_modules\zod\v4\mini\schemas.d.cts node_modules\zod\v4\mini\schemas.cjs node_modules\@modelcontextprotocol\sdk\dist\esm\types.d.ts.map node_modules\@modelcontextprotocol\sdk\dist\cjs\types.d.ts.map node_modules\zod\v4\core\schemas.js node_modules\zod\v4\core\schemas.d.ts node_modules\zod\v4\core\schemas.d.cts node_modules\zod\v4\core\schemas.cjs node_modules\zod\v4\core\api.js node_modules\zod\v4\core\api.d.ts node_modules\zod\v4\core\api.d.cts node_modules\zod\v4\core\api.cjs node_modules\zod\v4\classic\schemas.js node_modules\zod\v4\classic\schemas.d.ts node_modules\zod\v4\classic\schemas.d.cts node_modules\zod\v4\classic\schemas.cjs node_modules\agents\dist\browser\tanstack-ai.d.ts node_modules\zod\src\v4\mini\tests\string.test.ts node_modules\agents\dist\chat\react.d.ts node_modules\zod\src\v4\mini\schemas.ts node_modules\miniflare\dist\src\workers\shared\zod.worker.js.map node_modules\agents\dist\observability\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\ai-sdk\index.d.ts node_modules\agents\dist\chat\index.d.tsTool call: Grep
{ "pattern": "v7|export (declare )?(function|const)", "path": "node_modules\\agents\\dist\\observability\\ai\\index.d.ts", "output_mode": "content", "-i": true }Tool output
7:/** Instrumentation options for the AI SDK v6 and v7 wrapper. */Tool call: Read
{ "file_path": "C:\\Users\\haya0\\AppData\\Local\\Temp\\ludion-bench-PSDCF0\\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 35Agent
The function is **`wrapAISDK`**, exported from `agents/observability/ai` (`node_modules/agents/dist/observability/ai/index.d.ts:24`). You pass it the AI SDK namespace, for example `wrapAISDK(ai, options)`, and it returns the same namespace with tracing added. It works with both AI SDK v6 and v7. Its optional `AISDKInstrumentationOptions` are `storeMessages` and `storeTools`, which both default to `false`, and `includeRuntimeContext`, which emits the context keys you list as `cloudflare.agents.runtime_context.{key}` attributes.