Skip to content

Conversation

@Cirilla-zmh
Copy link
Member

Fixes #2721 #1835

Changes

Add JSON schema definition for gen_ai.tool.definitions.

Important

Pull requests acceptance are subject to the triage process as described in Issue and PR Triage Management.
PRs that do not follow the guidance above, may be automatically rejected and closed.

Merge requirement checklist

  • CONTRIBUTING.md guidelines followed.
  • Change log entry added, according to the guidelines in When to add a changelog entry.
    • If your PR does not need a change log, start the PR title with [chore]
  • Links to the prototypes or existing instrumentations (when adding or changing conventions)

Change-Id: I63f11ca8081f71b55b793ec88f35ef64bbace8e6
Co-developed-by: Cursor <noreply@cursor.com>
@Cirilla-zmh Cirilla-zmh requested review from a team as code owners October 20, 2025 11:45
@Cirilla-zmh Cirilla-zmh moved this from Untriaged to Awaiting codeowners approval in Semantic Conventions Triage Oct 20, 2025
Change-Id: Ib6133b3019195e4fa9a54d329ff4b891a281d208
Co-developed-by: Cursor <noreply@cursor.com>
@Cirilla-zmh Cirilla-zmh force-pushed the minghui/tool_definitions branch from 76f99f0 to 2a15973 Compare October 20, 2025 12:46
@github-actions github-actions bot added enhancement New feature or request area:gen-ai labels Oct 20, 2025
@Cirilla-zmh
Copy link
Member Author

This is the continued PR of #2793

Change-Id: Ie116f8bcb9e758b026596b797569b27496b35521
Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: If96268fc1b4d3cd64c0a10437a968cbe5ec83d98
Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Ic5480fbdb1058a2e1ace084c8ce3735484f91c06
Co-developed-by: Cursor <noreply@cursor.com>
@Cirilla-zmh Cirilla-zmh moved this from Awaiting codeowners approval to Needs More Approval in Semantic Conventions Triage Nov 18, 2025
"metadata": {},
"outputs": [],
"source": [
"class FunctionToolDefinition(BaseModel):\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could it extend GenericToolDefinition? then it would reuse type, name and description.

Comment on lines +306 to +309
It's expected to be an array of objects, each representing a tool definition,
and the structure of the array is expected to match the [Tool Definitions JSON Schema](/docs/gen-ai/gen-ai-tool-definitions.json).
In case a serialized string is available to the instrumentation, the instrumentation
SHOULD do the best effort to deserialize it to an array.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It's expected to be an array of objects, each representing a tool definition,
and the structure of the array is expected to match the [Tool Definitions JSON Schema](/docs/gen-ai/gen-ai-tool-definitions.json).
In case a serialized string is available to the instrumentation, the instrumentation
SHOULD do the best effort to deserialize it to an array.
Instrumentations MUST follow [Tool Definitions JSON Schema](/docs/gen-ai/gen-ai-tool-definitions.json)

There is no need to mention array - it's already in the definition. Also no need to mention deserialization - it's already explicitly required by a MUST.

This is also consistent with how we define input and output messages.

" \"\"\"\n",
" type: str = Field(description=\"The type of the tool.\")\n",
" name: str = Field(description=\"The name of the tool.\")\n",
" description: str = Field(None, description=\"The description of the tool.\")\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a generic property? I don't see it being used on most tools - https://platform.openai.com/docs/api-reference/responses/create#responses_create-tools, let's not add it as generic?

Comment on lines +315 to +318
If instrumentations can reliably deserialize and extract the tool definitions,
it's RECOMMENDED to only populate required fields (`name`, `type`) of the definition
objects by default. Otherwise, it's NOT RECOMMENDED to populate it by default.
Instrumentations MAY provide a way to enable populating this attribute.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, just more concise rephrasing:

Suggested change
If instrumentations can reliably deserialize and extract the tool definitions,
it's RECOMMENDED to only populate required fields (`name`, `type`) of the definition
objects by default. Otherwise, it's NOT RECOMMENDED to populate it by default.
Instrumentations MAY provide a way to enable populating this attribute.
It’s RECOMMENDED to populate all required attributes on each tool
definition by default. Instrumentations MAY allow to enable populating
non-required properties.

(instrumentations that can't "reliably deserialize and extract the tool definitions" would not populate the attribute at all)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gen-ai enhancement New feature or request

Projects

Status: Needs More Approval

Development

Successfully merging this pull request may close these issues.

Define schema for Tool Definitions for Single and Multi-Agent Spans

4 participants