Fix serialization inconsistency in MultiStepAgent.to_dict/from_dict for managed_agents by hazrmard · Pull Request #1577 · huggingface/smolagents (original) (raw)
Thanks for spotting the issue and proposing a fix.
Finally, I have aligned both the to_dict and from_dict methods to use a list instead of a dict for serializing managed_agents. This reduces redundant information (since the agent name is already stored within each agent's dict) and also aligns the behavior with how tools are serialized.
Final PR Changes:
- Modify
from_dictto properly handle the list format and reconstruct managed agents correctly. - Add
test_multiagent_to_dict_from_dict_roundtripto verify that round-trip serialization and deserialization work as expected.