Description
SerializationMixin.to_dict() serializes framework objects when they are direct list items or dictionary values, but it stops after one container level. A SerializationProtocol object nested inside a combination such as dict -> list -> dict remains in the returned mapping. As a result, SerializationMixin.to_json() raises TypeError for otherwise supported nested state.
Expected: supported objects are recursively converted at any list/dictionary depth, while unsupported values keep the existing behavior of being skipped.
Actual: nested supported objects are returned unchanged and cannot be JSON encoded.
Code Sample
from agent_framework._serialization import SerializationMixin
class Item(SerializationMixin):
def __init__(self, value: str):
self.value = value
class Container(SerializationMixin):
def __init__(self, payload: dict):
self.payload = payload
container = Container({"groups": [{"items": [Item("example")]}]})
container.to_json()
Error Messages / Stack Traces
TypeError: Object of type Item is not JSON serializable
Package Versions
agent-framework-core: 1.14.0 and current main (ab6c4d2dc8573071d7f73fd8c94a8cb15a2c78a2)
Python Version
Python 3.12.14
Additional Context
The same behavior occurs for list -> dict and deeper nested dictionaries. Direct list items and direct dictionary values already serialize correctly.
Description
SerializationMixin.to_dict()serializes framework objects when they are direct list items or dictionary values, but it stops after one container level. ASerializationProtocolobject nested inside a combination such asdict -> list -> dictremains in the returned mapping. As a result,SerializationMixin.to_json()raisesTypeErrorfor otherwise supported nested state.Expected: supported objects are recursively converted at any list/dictionary depth, while unsupported values keep the existing behavior of being skipped.
Actual: nested supported objects are returned unchanged and cannot be JSON encoded.
Code Sample
Error Messages / Stack Traces
Package Versions
agent-framework-core: 1.14.0and currentmain(ab6c4d2dc8573071d7f73fd8c94a8cb15a2c78a2)Python Version
Python 3.12.14
Additional Context
The same behavior occurs for
list -> dictand deeper nested dictionaries. Direct list items and direct dictionary values already serialize correctly.