Skip to content

Commit e5972e2

Browse files
authored
Python: Add incomplete details reason to AzureAIAgent error message (#12796)
### Motivation and Context When errors occur processing a run of an AzureAIAgent, we surface the error message but not the incomplete_details reason if it exists. <!-- 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 This PR adds handling for the incomplete details reason, if it exists, so it can be passed back via the error message. - Closes #12752 <!-- 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 😄
1 parent b7bb283 commit e5972e2

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

python/samples/getting_started_with_agents/openai_responses/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ In Semantic Kernel, we don't currently support the Computer User Agent Tool. Thi
1515
The Semantic Kernel Azure Responses Agent leverages Azure OpenAI's new stateful API.
1616
It brings together the best capabilities from the chat completions and assistants API in one unified experience.
1717

18-
Right now, there is no support with the `AzureResponsesAgent` for:
19-
20-
- Structured outputs
21-
- tool_choice
22-
- image_url pointing to an internet address
23-
- The web search tool is also not supported, and is not part of the 2025-03-01-preview API.
18+
For `AzureResponsesAgent` limitations, please see the latest [Azure OpenAI Responses API Docs](https://learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/responses?tabs=python-secure).
2419

2520
#### API Support
2621

python/semantic_kernel/agents/azure_ai/agent_thread_actions.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,15 @@ async def invoke(
199199
)
200200

201201
if run.status in cls.error_message_states:
202-
error_message = ""
202+
error_message = "None"
203203
if run.last_error and run.last_error.message:
204204
error_message = run.last_error.message
205+
incomplete_details_reason = "None"
206+
if run.incomplete_details and run.incomplete_details.reason:
207+
incomplete_details_reason = run.incomplete_details.reason
205208
raise AgentInvokeException(
206209
f"Run failed with status: `{run.status}` for agent `{agent.name}` and thread `{thread_id}` "
207-
f"with error: {error_message}"
210+
f"with error: {error_message} and incomplete details reason: {incomplete_details_reason}"
208211
)
209212

210213
# Check if function calling is required
@@ -738,12 +741,16 @@ async def _process_stream_events(
738741

739742
elif event_type == AgentStreamEvent.THREAD_RUN_FAILED:
740743
run_failed = cast(ThreadRun, event_data)
741-
error_message = (
742-
run_failed.last_error.message if run_failed.last_error and run_failed.last_error.message else ""
743-
)
744+
error_message = "None"
745+
if run_failed.last_error and run_failed.last_error.message:
746+
error_message = run_failed.last_error.message
747+
incomplete_details_reason = "None"
748+
if run_failed.incomplete_details and run_failed.incomplete_details.reason:
749+
incomplete_details_reason = run_failed.incomplete_details.reason
744750
raise RuntimeError(
745751
f"Run failed with status: `{run_failed.status}` for agent `{agent.name}` "
746-
f"thread `{thread_id}` with error: {error_message}"
752+
f"thread `{thread_id}` with error: {error_message} and incomplete details reason: "
753+
f"{incomplete_details_reason}"
747754
)
748755
else:
749756
break

0 commit comments

Comments
 (0)