Hello @Jubin Soni ,
Welcome to Microsoft Q&A .Thank you for reaching out to us.
The behavior observed is primarily due to how the Azure AI Agents streaming model is designed. During a run, the service emits different event types for response generation, tool execution, and run lifecycle updates. Because these events are surfaced independently, it is not always immediately clear which events represent assistant-generated text and which represent tool activity when relying solely on event names.
The recommended approach is therefore to distinguish events based on the type of the returned event_data object rather than string-matching event names. This provides a more reliable and maintainable implementation pattern across SDK versions.
The stream can emit several event types, each representing a different stage of execution:
- MessageDeltaChunk – Incremental assistant response text.
- RunStep – Execution step information, including tool calls.
- RunStepDeltaChunk – Incremental updates while a run step is executing.
- ThreadRun – Overall run lifecycle status.
- ThreadMessage – Completed assistant messages.
- AgentStreamEvent.ERROR / AgentStreamEvent.DONE – Stream termination events.
The practical implementation pattern is:
- Use MessageDeltaChunk events to process streamed assistant responses.
- Monitor RunStep events and check whether RunStep.type == "tool_calls".
- Use the associated RunStep.status (in_progress, completed, or failed) to track tool execution progress.
- Optionally monitor RunStepDeltaChunk events when additional visibility into tool execution is required.
For Azure AI Search and OpenAPI tools
- Use MessageDeltaChunk for streamed assistant text.
- Use RunStep and RunStepDeltaChunk for tool execution tracking and progress indicators.
- Treat these event streams independently to clearly separate tool activity from generated responses.
Azure AI Search and OpenAPI integrations are generally used as hosted (service-side) tools. In these scenarios, tool execution occurs within the Azure AI Foundry service rather than within the client application process. The OpenAPI tool documentation explicitly notes that execution does not occur client-side.
As a result, hosted tools are typically surfaced through:
- RunStep lifecycle events
- RunStepDeltaChunk updates
- Run status changes
- Streamed assistant responses
Hosted tools are generally monitored through these lifecycle events rather than through detailed client-side execution workflows. For this reason, RunStep and RunStepDeltaChunk are typically the most useful indicators for displaying progress such as "Searching..." or "Calling API..." while execution is in progress.
By contrast, requires_action is primarily associated with Function Tools, where execution occurs outside the service and tool outputs must be submitted back to continue processing.
If the expected tool events are not being observed:
- Verify the SDK version currently installed.
- Log both event_type and type(event_data) to identify the exact event objects emitted by the runtime.
- Confirm that the prompt is triggering Azure AI Search or OpenAPI tool invocation.
- Verify that the implementation is monitoring both RunStep.type == "tool_calls" and the associated step status.
- If possible, validate behavior against the latest supported azure-ai-agents and azure-ai-projects packages, as streaming event models have evolved across releases.
The following references might be helpful , please check them out
Thank you
Please "Accept" the answer with an "Upvote" if the response was helpful. This will be benefitting other community members who face the same issue.