Skip to content

Conversation

@dot-agi
Copy link
Member

@dot-agi dot-agi commented Jul 16, 2025

📥 Pull Request

📘 Description
Fix for tool calls in OpenAI Chat Completions API

🧪 Testing
Trust me bro arc 😉

@codecov
Copy link

codecov bot commented Jul 16, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../instrumentation/providers/openai/wrappers/chat.py 35.29% 11 Missing ⚠️
...instrumentation/providers/openai/stream_wrapper.py 25.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

This comment was marked as outdated.

@dot-agi dot-agi changed the title Fix/chat completions tool calls fix: OpenAI Chat Completions tool calls Jul 16, 2025
@dot-agi dot-agi requested a review from Copilot July 16, 2025 23:25

This comment was marked as outdated.

Copy link
Member

@Dwij1704 Dwij1704 left a comment

Choose a reason for hiding this comment

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

LGTM

@dot-agi dot-agi requested a review from Copilot July 16, 2025 23:34

This comment was marked as outdated.

@dot-agi dot-agi requested a review from Copilot July 16, 2025 23:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the OpenAI chat instrumentation to create dedicated tool-call spans instead of simply recording tool-call attributes.

  • Introduces a _create_tool_span helper to start child spans for each tool call
  • Updates handle_chat_attributes to invoke the new span helper for non-streaming calls
  • Modifies the streaming wrapper to import and use _create_tool_span instead of setting tool-call attributes

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
agentops/instrumentation/providers/openai/wrappers/chat.py Add _create_tool_span, adjust handle_chat_attributes to call it
agentops/instrumentation/providers/openai/stream_wrapper.py Import and use _create_tool_span in stream finalization
Comments suppressed due to low confidence (1)

agentops/instrumentation/providers/openai/stream_wrapper.py:18

  • [nitpick] Importing a private helper function (_create_tool_span) across modules couples implementation details. Consider promoting it to a public utility or moving it to a shared helper module.
from agentops.instrumentation.providers.openai.wrappers.chat import handle_chat_attributes, _create_tool_span

@dot-agi dot-agi force-pushed the fix/chat-completions-tool-calls branch from 19a989f to f564029 Compare July 17, 2025 00:03
@dot-agi dot-agi merged commit 67406e5 into main Jul 17, 2025
25 of 50 checks passed
@dot-agi dot-agi deleted the fix/chat-completions-tool-calls branch July 17, 2025 00:08
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.

3 participants