Skip to content

fix/openai-agents built in tools having no name - #967

Open
haneric00 wants to merge 3 commits into
mainfrom
fix-openai-agents-tools
Open

haneric00 wants to merge 3 commits into
mainfrom
fix-openai-agents-tools

Conversation

@haneric00

Copy link
Copy Markdown
Contributor

Small edge case in built in tool descriptions: built in tools are missing a name.

[{"type": "function", "name": "get_weather", "description": "...", "parameters": {...}},
 {"type": "web_search"}]

what is correct is
{"type":"web_search","name":"web_search"}

_set_tool_definitions copied name, description, and parameters from every tool if present. built in tools have none of these.

Fix is for built in tools to use their own name if they have one, otherwise the name defaults to the tool's type

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@haneric00
haneric00 requested a review from a team as a code owner November 6, 2026 06:40
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @haneric00's task in 1m 20s —— View job


Review

The fix is correct and minimal. Built-in Responses tools (web_search, file_search, …) have no name field, so the previous loop emitted {"type": "web_search"} which fails downstream schema validation that requires name. Keying built-ins by their type matches the OpenAI Responses API shape ({"type":"web_search","name":"web_search"}).

A few notes:

  1. Function-tool name fallback changed from "omit key" to "" — in _processor.py:733, if a function tool lacks a name (which shouldn't happen in practice), the output now always contains "name": "" instead of omitting the key. This is probably desirable for schema stability (gen-ai-tool-definitions likely requires name), but worth confirming it doesn't surprise anything downstream. If an empty string could be ambiguous, falling back to "function" (as you do for built-ins) would be more consistent.

  2. New isinstance(tool_type, str) guard at _processor.py:727-728 silently drops tools with a non-string type. Previously these would still be emitted. This is defensively correct, but if that ever happens with real inputs it will now disappear from telemetry without a trace — fine for this PR, just flagging.

  3. Test coverage is good — test_response_span_tool_definitions_include_builtin_tools exercises the mixed case (function + two built-ins) and asserts the full dict, which is exactly the regression this fixes. The schema validator call also protects against future drift.

No blocking issues. LGTM.
• fix-openai-agents-tools

@haneric00 haneric00 changed the title fix/openai-agents description naming fix/openai-agents built in tools having no name Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @haneric00's task in 2m 4s —— View job


Review

Re-reviewed after the latest push. The only new change since my prior review is the CHANGELOG entry — the code and test diff are unchanged.

CHANGELOG.md — entry is well-placed under ## Unreleased, correctly scoped as a fix, links to this PR, and accurately describes the behavior change (built-in tools now get a name defaulting to their type, so gen_ai.tool.definitions conforms to the semantic convention schema).

My earlier observations on _processor.py still stand and remain non-blocking:

  • _processor.py:733 — function-tool name fallback is "" instead of omitting the key. Fine for schema stability; consider "function" for consistency with the built-in fallback if an empty name ever becomes ambiguous downstream.
  • _processor.py:727-728 — non-string tool_type is silently dropped. Defensive, but will disappear from telemetry without a trace if ever encountered.
  • Test coverage via test_response_span_tool_definitions_include_builtin_tools plus the validate_otel_genai_schema check is appropriate and guards against regression.

No new issues. LGTM.
• fix-openai-agents-tools

if value is not None:
definition[key] = value
else:
# Built-in tools (web_search, file_search, ...) carry no name, so they are keyed by their type.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

find docs to see if built in tools have anything we can pull as data to match user defined tools

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also separate PR to propagate tool data up to invoke_agent span as it is missing data vs chat span

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @haneric00's task in 1m 14s —— View job


Review

The fix is correct, minimal, and well-tested.

Change summary

  • Built-in Responses tools (web_search, file_search, …) have no name, so _set_tool_definitions previously emitted {"type": "web_search"} and failed schema validation that requires name.
  • Now function tools and built-in tools are handled on separate branches; built-ins default name to type, function tools default name to "" for schema stability.
  • test_response_span_tool_definitions_include_builtin_tools covers the mixed case and asserts against the schema via validate_otel_genai_schema.

Prior review observations (already noted — not re-raising)

  • _processor.py:733 — function-tool name fallback is "" instead of omitting the key. Fine for schema stability; "function" would be more consistent with the built-in fallback, but non-blocking.
  • _processor.py:727-728 — non-string tool_type is silently dropped. Defensive, but will disappear from telemetry without a trace if ever encountered. Non-blocking.

Author has left TODOs on this PR to:

  1. Investigate whether built-in tools expose additional fields that could be surfaced (matching user-defined tools).
  2. Propagate tool data up to the invoke_agent span (separate PR).

New findings: none. LGTM.

Todo List

  • Read prior PR review comments to dedupe
  • Review full PR diff
  • Analyze changes in _processor.py and tests
  • Post findings (summary only — no new inline findings)
    • fix-openai-agents-tools

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant