fix: don't pass parent kwargs to managed agents in from_dict()#2063
Open
MaxwellCalkin wants to merge 1 commit intohuggingface:mainfrom
Open
fix: don't pass parent kwargs to managed agents in from_dict()#2063MaxwellCalkin wants to merge 1 commit intohuggingface:mainfrom
MaxwellCalkin wants to merge 1 commit intohuggingface:mainfrom
Conversation
When deserializing agents with from_dict(), the parent agent's **kwargs (including additional_authorized_imports) were passed to child managed agents, overriding their custom configurations. This caused child agents to lose their custom authorized_imports after deserialization, leading to runtime errors when executing code that depends on those imports. The fix removes **kwargs from the managed agent from_dict() call since each managed agent's serialized dict already contains all the information needed for its own deserialization. Fixes huggingface#1849
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Fixes #1849
When deserializing agents with
from_dict(), the parent agent's**kwargs(includingadditional_authorized_imports) were passed to child managed agents via:This caused child agents to lose their custom configurations after deserialization. For example, a child agent with
additional_authorized_imports=["sympy"]would lose that import because the parent's kwargs (withoutsympy) overwrote it viacode_agent_kwargs.update(kwargs)inCodeAgent.from_dict().Fix
Remove
**kwargsfrom the managed agentfrom_dict()call inMultiStepAgent.from_dict():Each managed agent's serialized dict already contains all the information needed for its own deserialization — there is no reason to propagate the parent's kwargs down to children.
Test plan
CodeAgentwith a managed sub-agent that has customadditional_authorized_imports(e.g.,["sympy"]).to_dict()and deserialize with.from_dict()authorized_importsafter round-trip🤖 Generated with Claude Code