Update item type check for workflow actions#45260
Update item type check for workflow actions#45260spotakash wants to merge 1 commit intoAzure:mainfrom
Conversation
As per SDK, package name correction and item payload correction. Else there will be error indicates event.item is None when you try to access event.item.type. Add a null check before comparing the type
|
Thank you for your contribution @spotakash! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Pull request overview
This PR updates the streaming event handling in the azure-ai-projects multi-agent workflow sample to avoid errors when event.item is missing, and adjusts the item type check logic.
Changes:
- Adds a null check for
event.itembefore readingevent.item.typeduring streaming. - Replaces the workflow-action type comparison with a string-based check.
- Updates the imported model symbol list in the sample.
| PromptAgentDefinition, | ||
| WorkflowAgentDefinition, | ||
| ItemResourceType, | ||
| ItemResource, |
There was a problem hiding this comment.
ItemResource is imported but never used in this sample. This will trigger unused-import linting in many CI configurations. If the intent is to avoid string literals for the item type check, consider importing/using ItemResourceType instead; otherwise remove this import entirely.
| ItemResource, |
| if ( | ||
| event.type == "response.output_item.added" or event.type == "response.output_item.done" | ||
| ) and event.item.type == ItemResourceType.WORKFLOW_ACTION: | ||
| ) and event.item is not None and event.item.type == "workflow_action": |
There was a problem hiding this comment.
This condition hard-codes the item type as the string "workflow_action". The SDK already defines this value in ItemResourceType.WORKFLOW_ACTION, which is safer (avoids typos and stays aligned if the constant ever changes). You can keep the new event.item is not None guard, but compare event.item.type against the enum constant instead of a raw string.
As per SDK, package name correction and item payload correction. Else there will be error indicates event.item is None when you try to access event.item.type. Add a null check before comparing the type
Description
Please add an informative description that covers that changes made by the pull request and link all relevant issues.
If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines