You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarify Copy Type for tools and handoffs in Agent.clone() Documentation #1293
The documentation for Agent.clone() does not explain whether the tools and handoffs lists are shallow-copied or deep-copied.
This leads to ambiguity when cloning agents, as developers may accidentally share references to the same tool or handoff objects, causing unintended side effects.
From reviewing the implementation, both lists are shallow-copied:
New list objects are created.
The elements inside (tools and handoffs) remain the same references.
Thanks for the feedback. The docstring of the clone() method can mention this and the reference page can have the information for developers. I will be working on the class enhancement for #1238, so I will improve the code comment as well.
Activity
seratch commentedon Jul 29, 2025
Thanks for the feedback. The docstring of the clone() method can mention this and the reference page can have the information for developers. I will be working on the class enhancement for #1238, so I will improve the code comment as well.
abdul-kabir-jawed commentedon Jul 29, 2025
Thanks for the update! Glad to hear this will be improved in the upcoming enhancement for #1238.
I'd be happy to help by opening a small PR that:
Updates the
Agent.clone()docstring to clarify thattoolsandhandoffsare shallow‑copied,Adds the clarification to the reference docs, and
Includes a simple test verifying the shallow‑copy behavior.
seratch commentedon Jul 29, 2025
Thanks for sending the PR! Once the lint issue is resolved, your change will be merged
abdul-kabir-jawed commentedon Jul 30, 2025
Fixed the lint issues. Ready for review again!