mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Title: DevUI Fix WorkflowFailedEvent error extraction (#2706)
* Title: Fix WorkflowFailedEvent error extraction to use details instead of error Body: Summary Fixed WorkflowFailedEvent mapping to extract error message from details.message instead of non-existent error attribute Added support for including details.extra context in error messages when present Problem The WorkflowFailedEvent handler in _mapper.py was reading event.error, but WorkflowFailedEvent uses a details attribute (of type WorkflowErrorDetails), not error. This caused all workflow failures to display "Unknown error" in the UI instead of the actual error message. Fix Updated the handler to match the pattern already used by ExecutorFailedEvent: Read from event.details instead of event.error Extract details.message for the error text Include details.extra context when available * improve error handling consistency
This commit is contained in:
committed by
GitHub
Unverified
parent
1e6aedb3f9
commit
d889fa6f87
@@ -596,6 +596,31 @@ async def test_workflow_failed_event(mapper: MessageMapper, test_request: AgentF
|
||||
response = failed_events[0].response
|
||||
assert response.status == "failed"
|
||||
assert response.error is not None
|
||||
# Verify error message is correctly extracted from details.message (not "Unknown error")
|
||||
assert "Workflow failed due to test error" in response.error.message
|
||||
assert "Unknown error" not in response.error.message
|
||||
|
||||
|
||||
async def test_workflow_failed_event_with_extra(mapper: MessageMapper, test_request: AgentFrameworkRequest) -> None:
|
||||
"""Test WorkflowFailedEvent includes extra context when available."""
|
||||
from agent_framework._workflows._events import WorkflowErrorDetails, WorkflowFailedEvent
|
||||
|
||||
details = WorkflowErrorDetails(
|
||||
error_type="ValidationError",
|
||||
message="Input validation failed",
|
||||
executor_id="validation_executor",
|
||||
extra={"field": "email", "reason": "invalid format"},
|
||||
)
|
||||
event = WorkflowFailedEvent(details=details)
|
||||
events = await mapper.convert_event(event, test_request)
|
||||
|
||||
assert len(events) == 1
|
||||
assert events[0].type == "response.failed"
|
||||
response = events[0].response
|
||||
# Verify both the message and extra context are included
|
||||
assert "Input validation failed" in response.error.message
|
||||
assert "extra:" in response.error.message
|
||||
assert "email" in response.error.message
|
||||
|
||||
|
||||
async def test_workflow_failed_event_with_traceback(mapper: MessageMapper, test_request: AgentFrameworkRequest) -> None:
|
||||
|
||||
Reference in New Issue
Block a user