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)

@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 <[email protected]>
@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 <[email protected]>
"source": [
"class ToolType(str, Enum):\n",
" FUNCTION = \"function\"\n",
" CUSTOM = \"custom\"\n",
Copy link
Member

Choose a reason for hiding this comment

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

bringing @alexmojaki 's comment here https://github.com/open-telemetry/semantic-conventions/pull/2793/files#r2369871417

Custom tools are only supported by OpenAI Chat API and are not even available in the Responses API - https://platform.openai.com/docs/api-reference/responses/create#responses-create-tools

  1. I'd suggest to remove this enum member
  2. The ToolDefinition below only works for functions and should only be used when ToolType is function.
  3. We need to leave a room to support non-function tool definitions (e.g. file search) and their parameters. I.e. we'd need something like
     ToolDefinition = Union[
         FunctionDefinition,
         GenericToolDefinition,  # Catch-all for any other type
         # Add other tool definition types here as needed,
         # e.g. file search, code interpreter, etc
     ]

" type: Union[ToolType, str] = Field(description=\"Type of the tool.\")\n",
" name: str = Field(description=\"Name of the tool.\")\n",
" description: str = Field(None, description=\"Description of the tool.\")\n",
" parameters: Any = Field(\n",
Copy link
Member

Choose a reason for hiding this comment

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

see comment above - parameters and response are specific to functions and don't necessarily work for non-function tools (e.g. file search)

format is not supported and SHOULD be recorded in structured form otherwise.

If instrumentations can reliably deserialize and extract the tool definitions,
it's RECOMMENDED to only populate required fields (`name`, `type`) of the definition
Copy link
Member Author

@Cirilla-zmh Cirilla-zmh Oct 21, 2025

Choose a reason for hiding this comment

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

Whether we need to capture 'name' & 'type' by default, considering they are important informations and have no sensitive/huge content? cc @ShipraJain01 @lmolkova

Here is a prototype from spring-ai instrumentation:

options.getToolCallbacks().stream()
    .map(
        toolCallback -> {
          String name = toolCallback.getToolDefinition().name();
          String type = "function";
          if (messageCaptureOptions.captureMessageContent()) {
            return ToolDefinition.create(
                type, name, toolCallback.getToolDefinition().description(), toolCallback.getToolDefinition().getArguments());
          } else {
            return ToolDefinition.create(type, name, null, null);
          }
        })
    .filter(Objects::nonNull)
    .forEach(toolDefinitions::append);

Copy link
Contributor

Choose a reason for hiding this comment

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

@lmolkova I feel like this should just be a python script with comments and docstrings, reviewing this notebook format in github is annoying

Copy link
Member

Choose a reason for hiding this comment

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

+1 for a python script here.

Copy link
Member

Choose a reason for hiding this comment

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

maybe a markdown file also works here, embedding the code in the markdown file and and also with the output .

python code
this is the output of above code

Copy link
Member

Choose a reason for hiding this comment

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

+1 for a python script here.

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: Awaiting codeowners approval

Development

Successfully merging this pull request may close these issues.

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

4 participants