Skip to content

Fix serialization inconsistency in MultiStepAgent.to_dict/from_dict for managed_agents #1577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 24, 2025

Conversation

hazrmard
Copy link
Contributor

Fixes #1576

The MultiStepAgent.to_dict() method returns managed_agents as a dict instead of a list.

The MultiStepAgent.from_dict() class method parses the managed_agents dict and turns it back into a list of MultiStepAgent instances to be passed as arguments to instantiate the class.

hazrmard and others added 4 commits July 17, 2025 21:53
The  method parses the managed_agents dict and turns it back into a list of MultiStepAgent instances to be passed as arguments to instantiate the class.
@albertvillanova albertvillanova changed the title Serialize MultiStepAgents with managed agents in a dict. Fix serialization inconsistency in MultiStepAgent.to_dict/from_dict for managed_agents Jul 24, 2025
Copy link
Member

@albertvillanova albertvillanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_dict to properly handle the list format and reconstruct managed agents correctly.
  • Add test_multiagent_to_dict_from_dict_roundtrip to verify that round-trip serialization and deserialization work as expected.

@albertvillanova albertvillanova merged commit d001334 into huggingface:main Jul 24, 2025
3 checks passed
@hazrmard hazrmard deleted the deserialize_managed_agents branch July 25, 2025 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: MultiStepAgent.to_dict() and from_dict() do not use same data structure for managed_agents, causing from_dict() to fail.
2 participants