Skip to content

Conversation

@M-Hietala
Copy link
Contributor

adding tracing support for bing custom search tool

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 adds tracing support for Bing Custom Search tool in the Azure AI Projects SDK. The changes enable proper telemetry instrumentation to track both Bing Custom Search tool calls and their outputs, distinguishing them from similar remote function call patterns.

Key Changes

  • Added a new _emit_tool_output_event helper method to emit tool output events with the appropriate role and event type
  • Updated dictionary keys for output_items to use (id, type) tuples instead of just id to prevent call and output items with the same ID from overwriting each other
  • Enhanced the generic tool call/output handler to support Pydantic v2 model_dump() method in addition to existing as_dict() support
  • Split handling of remote_function_call (the call) and remote_function_call_output (the output) into separate code paths with appropriate event types and field extraction logic

Comment on lines +2678 to +2679
# Debug sync wrapper initialization
# Return wrapped stream
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

[nitpick] These debug comments appear to be leftover from development and don't add value to the code. They should be removed to keep the codebase clean.

Suggested change
# Debug sync wrapper initialization
# Return wrapped stream

Copilot uses AI. Check for mistakes.
# Always try to include common ID fields (safe, needed for correlation)
for id_field in ["id", "call_id"]:
if hasattr(output_item, id_field):
tool_output["id" if id_field == "id" else "id"] = getattr(output_item, id_field)
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The conditional expression "id" if id_field == "id" else "id" always evaluates to "id" regardless of the condition. This means when id_field is "call_id", the code still assigns to tool_output["id"] instead of mapping call_id to id. This appears to be a copy-paste error.

This should be: tool_output["id"] = getattr(output_item, id_field) to correctly handle both field names.

Suggested change
tool_output["id" if id_field == "id" else "id"] = getattr(output_item, id_field)
tool_output["id"] = getattr(output_item, id_field)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants