Skip to content

Record custom tool calls from OpenAI chat completions - #2647

Merged
alexmojaki merged 2 commits into
pydantic:mainfrom
pcbeingused333:fix/openai-chat-custom-tool-calls
Oct 26, 2026
Merged

alexmojaki merged 2 commits into
pydantic:mainfrom
pcbeingused333:fix/openai-chat-custom-tool-calls

Conversation

@pcbeingused333

@pcbeingused333 pcbeingused333 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

A chat completions response can call a custom tool: the tool call has type: "custom" and a free-form custom.input string instead of JSON function.arguments. convert_openai_response_to_semconv only handled function tool calls, so the custom ones were left out of gen_ai.output.messages. When such a call is replayed in the next request, convert_chat_completions_to_semconv looked for a function key that is not there and recorded a tool call with an empty name and no arguments.

Both conversions now handle custom tool calls: the part gets the call id, custom.name as the name and custom.input as the arguments.

Tests: test_convert_openai_response_custom_tool_call converts a message with one function call and one custom call, and test_convert_chat_completions_custom_tool_call_input converts a history with a custom call and its tool response. Both fail on main and pass here. The rest of test_openai.py gives the same result as main.

This change was made with Claude Code.

🤖 Generated with Claude Code

🤖 Generated with Claude Code

View guided diff

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  logfire-sdk/logfire/_internal/integrations/llm_providers
  openai.py
Project Total  

This report was generated by python-coverage-comment-action

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@alexmojaki
alexmojaki added this pull request to the merge queue Oct 26, 2026
Merged via the queue into pydantic:main with commit 18c86ef Oct 26, 2026
28 checks passed
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.

2 participants