Skip to content

fix: stop leaking parent kwargs to managed agents in from_dict#2318

Open
sharziki wants to merge 1 commit into
huggingface:mainfrom
sharziki:fix/1849-from-dict-kwargs-leak
Open

fix: stop leaking parent kwargs to managed agents in from_dict#2318
sharziki wants to merge 1 commit into
huggingface:mainfrom
sharziki:fix/1849-from-dict-kwargs-leak

Conversation

@sharziki
Copy link
Copy Markdown

Summary

Closes #1849

MultiStepAgent.from_dict() forwarded the caller's **kwargs to every managed agent's from_dict(). This caused parent-level overrides (e.g. max_steps=30) to silently replace the child's serialized values, breaking round-trip fidelity.

Changes

  • src/smolagents/agents.py: Remove **kwargs from the recursive from_dict() call at line 1043, so each managed agent reconstructs itself from its own serialized config only
  • tests/test_agents.py: Add test_from_dict_does_not_leak_parent_kwargs_to_managed_agents — verifies child max_steps stays at 5 when parent is overridden to 30

`MultiStepAgent.from_dict()` forwarded the caller's `**kwargs` to every
managed agent's `from_dict()`.  This caused parent-level overrides
(e.g. `max_steps=30`) to silently replace the child's serialized values,
breaking round-trip fidelity.

Remove `**kwargs` from the recursive `from_dict()` call so each managed
agent reconstructs itself from its own serialized config only.

Closes huggingface#1849
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.from_dict() passes **kwargs to managed agents, causing child agent configurations to be overridden

1 participant