Skip to content

Python: Azure AI Agent fails to emit intermediate messages for integrated tools (Code Interpreter/Bing) #11847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rutzsco opened this issue May 1, 2025 · 1 comment · Fixed by #11850
Assignees
Labels
agents bug Something isn't working python Pull requests for the Python Semantic Kernel

Comments

@rutzsco
Copy link

rutzsco commented May 1, 2025

For Azure AI Agents with integrated tools enabled (specifically Code Interpreter and Bing Grounding), the intermediate message callback is not being invoked to indicate when a tool call starts and completes. Without this capability, a Chat UI cannot show users the real-time steps taken to fulfill their requests.

To reproduce

  1. Create an agent with Bing Search and Code Interpreter enabled.
  2. Ask for the current weather in City, State.
  3. Observe that the intermediate message callback is not invoked during the search step.

Expected behavior
As described in the documentation, the callback function should fire for each integrated tool call in the Azure AI Agent Service:
https://learn.microsoft.com/en-us/semantic-kernel/frameworks/agent/agent-streaming?pivots=programming-language-python#handling-intermediate-messages-with-a-streaming-response

Platform

  • Language: Python
  • Package: pip version 1.29.0
  • AI model: OpenAI GPT-4o
  • IDE: VS Code
  • OS: Windows

Additional Information

While debugging I could see events coming back from the AI Agent Service but not handled in agent_thread_actions.py:

@rutzsco rutzsco added the bug Something isn't working label May 1, 2025
@markwallace-microsoft markwallace-microsoft added python Pull requests for the Python Semantic Kernel triage labels May 1, 2025
@github-actions github-actions bot changed the title Azure AI Agent fails to emit intermediate messages for integrated tools (Code Interpreter/Bing) Python: Azure AI Agent fails to emit intermediate messages for integrated tools (Code Interpreter/Bing) May 1, 2025
@rutzsco rutzsco changed the title Python: Azure AI Agent fails to emit intermediate messages for integrated tools (Code Interpreter/Bing) Azure AI Agent fails to emit intermediate messages for integrated tools (Code Interpreter/Bing) May 1, 2025
@rutzsco rutzsco changed the title Azure AI Agent fails to emit intermediate messages for integrated tools (Code Interpreter/Bing) Python: Azure AI Agent fails to emit intermediate messages for integrated tools (Code Interpreter/Bing)[/+] May 1, 2025
@rutzsco rutzsco changed the title Python: Azure AI Agent fails to emit intermediate messages for integrated tools (Code Interpreter/Bing)[/+] Python: Azure AI Agent fails to emit intermediate messages for integrated tools (Code Interpreter/Bing) May 1, 2025
@moonbox3 moonbox3 self-assigned this May 2, 2025
@moonbox3 moonbox3 removed the triage label May 2, 2025
@moonbox3 moonbox3 added the agents label May 2, 2025
@moonbox3
Copy link
Contributor

moonbox3 commented May 2, 2025

Hi @rutzsco, thanks for filing. #11850 has the fixes for these issues. Please do read through the PR description and let me know if you have any questions.

One note as I called out in the PR description: the code_interpreter tool call is not handled in the traditional SK plugin tool call sense -- meaning, we're not returning FunctionCallContent with the arguments - the code interpreter inputs (Python code) is returned as StreamingTextContent for the invoke_stream path with the metadata populated with {"code": True}. This is similar to how it's done for the AzureAssistantAgent/OpenAIAssistantAgent.

For the Bing tool, this was a complete gap. I added support for it, with the caveat that the streaming case isn't currently returning the requesturl as part of the received tool call. I raised the issue with the SDK team.

github-merge-queue bot pushed a commit that referenced this issue May 6, 2025
…unding for AzureAIAgent (#11850)

### Motivation and Context

The AzureAIAgent streaming event path for handling streaming code output
as well as both streaming and non-streaming Bing Grounding tool calls
were missing in the current implementation. This PR adds handling for
those two scenarios.

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

### Description

Updates to allow for proper handling of streaming code using the
AzureAIAgent
- code_interpreter: note that the code interpreter tool call is handled
as returning `StreamingTextContent` with the `metadata` dict configured
with `{"code": True}`.
- bing_grounding: support for the Bing Grounding Tool is added. There is
a current issue with streaming events and the Bing Grounding tool - the
`requesturl` as part of the tool call is coming back empty. This issue
has been raised with the appropriate team. Both streaming and
non-streaming do properly return the `StreamingAnnotationContent` or
`AnnotationContent` respectively.
- Samples were added to show interaction with the AzureAIAgent and these
tools, some also showing how to use the `on_intermediate_message`
callback.
- Fixes #11847

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents bug Something isn't working python Pull requests for the Python Semantic Kernel
Projects
Status: No status
3 participants