Repository navigation
feat(server-utils): Send gen_ai.tool.definitions in the documented format - #26445
sentry-junior[bot] wants to merge 5 commits into
Conversation
…rmat Co-Authored-By: Alexander Webb <alexander.webb@sentry.io>
size-limit report 📦Compared: 1d6f1ff (PR test merge using develop at 8c549b9) Against: 8c549b9 (develop) · base run #67421 ✅ Baseline matches: this diff contains only this PR's changes.
|
Optional E2E testsSome optional checks were not successful. They do not block the merge. 6 not successful, 55 successful. See the run.
Successful checks
|
…efinitions-format # Conflicts: # packages/server-utils/src/integrations/vercel-ai/vercel-ai-dc-subscriber.ts
…efinitions-format # Conflicts: # packages/server-utils/src/ai/pi-ai/chat.ts
…efinitions-format # Conflicts: # packages/server-utils/src/ai/langchain/utils.ts # packages/server-utils/src/ai/langgraph/agent-span.ts
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3b37818. Configure here.
| * Tools that a provider runs itself (such as OpenAI's `web_search`) have no schema and are kept as they are. | ||
| */ | ||
| export function getToolDefinitionsAttribute(tools: unknown): string | undefined { | ||
| const definitions = Array.isArray(tools) ? tools.map(toGenAiToolDefinition).filter(tool => tool !== undefined) : []; |
There was a problem hiding this comment.
Chained map and filter loops
Low Severity
The SDK performance convention asks to avoid chaining .map and .filter over the same array; a classic for loop is the expected replacement. getToolDefinitionsAttribute walks tools twice this way. I flagged this because it is called out in the PR review rules.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 3b37818. Configure here.
…efinitions-format # Conflicts: # packages/server-utils/src/ai/openai/index.ts


What
Every gen AI integration now sends
gen_ai.tool.definitionsas a flat list of{ type: "function", name, description, parameters }objects, which is the documented format. Before, each integration sent its provider's raw format: OpenAI Chat Completions and Mistral nested the tool underfunction, Anthropic usedinput_schema, Bedrock usedinputSchema.json, Google usedparametersJsonSchema, and Mastra sent a list of names.Why
The product has to read one shape, not one per provider. Tools that the provider runs itself (OpenAI
web_search*, Anthropic server tools, Vercel provider tools) have no schema, so they keep their owntypeand are sent unchanged.Some smaller behavior changes:
parameters. Before, they only had the name and description.lc_kwargs.schema) are left out instead of being sent as Zod internals.toolsentries withoutfunctionDeclarations(such asgoogleSearch) no longer addnullentries.strictandcache_controlare dropped.Open question for review: should this count as a breaking change for anyone who parses the attribute? The attribute name stays the same, but its value changes shape.
The Cloudflare google-genai suite only had its expected string updated. I didn't run it locally.
via webb.
--
View Session [Sentry]