Repository navigation
fix: add shared cases for tool definitions in the conventions' shape - #117
Conversation
Every implementation of the tool-definition rules (both SDKs and the sink) runs these cases and asserts that rewriting its own output changes nothing.
Automated reviewNo blocking issues. The 38 cases are real provider shapes plus the edge cases from the last review round. Every What I checked
Should fix
Suggestions
Nits
|
…pty tool names OpenAI's MCP tool also carries authorization, an OAuth access token: it goes with headers for mcp and any <provider>.mcp type. A Chat Completions custom tool nests its fields under custom; they are lifted as function's are and the tool stays a custom tool, unless the lifted tool is Anthropic's custom tool with an input_schema. An empty name is no name, as for tool calls.
|
Addressed in
44 cases, expectations from the Python SDK (rius-sdk-python#286 Follow-up, not in this PR: scrubbing credentials from native |
The AI SDK's openai.mcp provider tool holds authorization and headers in args; a tool written as mcp or <provider>.mcp loses them there too.
Adds
sdk_cases/tool_definitions.json: one shared set of cases for the rules that rewritegen_ai.tool.definitionsinto the conventions' shape. The Python SDK, the TypeScript SDK and the sink each implement those rules, and until now each copied the cases into its own tests.Each case gives
toolsin a provider's own shape, the span'sprovider, andexpected, the rewritten list's compact JSON (key order included). Every implementation must writeexpected, and rewriting its own output must writeexpectedagain. That second check is the one that keeps the three ports from drifting into a shape the sink would rewrite a second time.Coverage:
strict) and chatcustom, Responses function, built-ins, freeformcustomandmcp; legacyfunctions; Anthropic custom (withcache_control),type: custom, server tools; Gemini snake and camel declarations,parametersJsonSchema/parameters_json_schema, built-ins beside declarations; BedrocktoolSpec,cachePoint,systemTool,inputSchemawithoutjson; Vercel AI SDK function and provider tools; MCP tools withinputSchema/outputSchema/annotations.input_schema/inputSchema, nameless declarations and the rest of a Gemini tool going through the single-tool rule, a nestedfunctionbeside a top-levelname,parameters: null(a Pythonmodel_dump()of a Gemini declaration),type: "", an MCP tool'sheadersandauthorization(dropped, formcpand any<provider>.mcptype, since they carry credentials), Chat Completionscustomtools (nested members lifted, still a custom tool) beside Anthropic'scustomwithinput_schema(a function tool), an emptyname(no name, so no function tool), non-object and non-string junk, a__proto__key, and the empty list.The expected results come from the Python SDK. The cases hold no float and no integer-like key, whose text differs by language.
sdk_cases/README.mdlists the file and notes that the sink vendors it as well.tests/test_sdk_cases.pychecks that the file is well formed and thatexpectedis compact JSON.Consumers (each vendors this file from this branch for now, and must re-sync from
mainafter this is squash-merged):Review follow-ups
Six new cases (44 in all), with
expectedfrom the Python SDK at glassflow/rius-sdk-python#286bcc1db8, each a fixed point:openai_responses_mcp_authorization_dropped: an MCP connector tool withauthorization, and one with bothauthorizationandheaders.mcp_credentials_dropped_for_any_provider_prefix:azure.mcp, a Vercelprovidertool withid: "openai.mcp", and a non-MCP tool that keeps itsauthorization.openai_chat_custom_lifted,custom_nested_not_lifted_over_a_name,custom_lifted_with_input_schema_is_a_function: the Chat Completions custom shape, pinned apart from Anthropic'scustom(anthropic_explicit_custom_type).empty_name_is_no_name: an empty name on a bare tool, acustomtool withinput_schema, a BedrocktoolSpecand a Gemini declaration, and a nestedfunctionlifted over an empty top-level name.empty_type_and_namenow expects{"name":""}kept as given, not a function tool with an empty name.aboutandsdk_cases/README.mdsay so. The file is vendored byte-identically (sha1f3374f7a) into all three consumers.pytest(1167 passed) and thetools/check_*.pychecks exit 0.vercel_mcp_provider_tool_args_credentials_dropped(45 in all):providerandprovider-definedopenai.mcptools loseauthorization/headersfromargs, and anopenai.web_searchtool keeps anauthorizationin itsargs. Vendored byte-identically (sha1a41a876f).Not in scope, as a follow-up: scrubbing credentials from definitions the rules do not rewrite. A span's native
gen_ai.tool.definitionswritten by another instrumentation, and raw request bodies (OpenInference / OpenLLMetryinput.value), keep an MCP tool'sheaders/authorization. Both are content-gated.