fix(devui): Fix serialization of dataclass events in workflow mapper #3711
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a serialization bug in the devui package that causes
PydanticSerializationErrorwhen using workflows with group chat orchestrators.Problem
When running
devuiwith a workflow that usesAgentBasedGroupChatOrchestrator, users encounter:Root Cause
The
_convert_workflow_eventmethod in_mapper.pyhandles legacy workflow events by serializing theirdatafield. The original implementation only checked forto_dict()method:However,
GroupChatResponseReceivedEvent.datacontainsAgentExecutorResponse, which is a dataclass (not aSerializationMixin). This dataclass contains nestedAgentResponseobjects that Pydantic cannot serialize directly.Solution
The
MessageMapperclass already has a_serialize_value()method that properly handles:SerializationMixinobjects (viato_dict())Changed to use this existing method instead of the limited
to_dict()check.Testing
devui . --log-level DEBUGrunning a workflow withAgentBasedGroupChatOrchestratorGroupChatResponseReceivedEventserializes correctly without errorsChanges
python/packages/devui/agent_framework_devui/_mapper.py_serialize_value()for legacy event serializationBackwards Compatibility
✅ Fully backwards compatible - This change:
to_dict()still serialize correctly via_serialize_value()