Repository navigation
Clarify shallow-copy behavior of tools and handoffs in Agent.clone() - #1296
Merged
seratch merged 18 commits intoAug 1, 2025
Merged
Conversation
seratch
requested changes
Jul 29, 2025
seratch
left a comment
Member
There was a problem hiding this comment.
Can you fix the lint error?
uv run ruff check
src/agents/agent.py:230:81: W291 Trailing whitespace
|
228 | Notes:
229 | - Uses `dataclasses.replace`, which performs a **shallow copy**.
230 | - Mutable attributes like `tools` and `handoffs` are shallow‑copied:
| ^ W291
231 | new list objects are created only if overridden, but their contents
232 | (tool functions and handoff objects) are shared with the original.
|
= help: Remove trailing whitespace
src/agents/agent.py:231:82: W291 Trailing whitespace
|
229 | - Uses `dataclasses.replace`, which performs a **shallow copy**.
230 | - Mutable attributes like `tools` and `handoffs` are shallow‑copied:
231 | new list objects are created only if overridden, but their contents
| ^ W291
232 | (tool functions and handoff objects) are shared with the original.
233 | - To modify these independently, pass new lists when calling `clone()`.
|
= help: Remove trailing whitespace
Found 2 errors.
No fixes available (2 hidden fixes can be enabled with the `--unsafe-fixes` option).
make: *** [Makefile:16: lint] Error 1
Error: Process completed with exit code 2.
Fixed ruff lint errors (W291) caused by trailing whitespace in the docstring.
abdul-kabir-jawed
left a comment
Contributor
Author
There was a problem hiding this comment.
Fixed the lint issues. Ready for review again!
Member
|
still failing |
abdul-kabir-jawed
left a comment
Contributor
Author
There was a problem hiding this comment.
Appreciate the review! I’ve addressed the test failure and pushed a fix. Waiting for checks to pass.
Member
|
lint is now fine, but the test is failing (thanks for adding the tests!) |
abdul-kabir-jawed
left a comment
Contributor
Author
There was a problem hiding this comment.
The updated test file should resolve the failure. Could you please review the latest Actions logs once the checks rerun? If the test still fails, I’d appreciate it if you could share the specific error message, and I’ll address it promptly
Member
|
tests: old_versions: |
Member
|
The lint job is failing now. Can you resolve it? |
seratch
enabled auto-merge (squash)
August 1, 2025 15:12
seratch
approved these changes
Aug 1, 2025
vcshih
pushed a commit
to veris-ai/openai-agents-python
that referenced
this pull request
Aug 15, 2025
This was referenced Aug 16, 2026
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.
Fixes #1293
This PR clarifies that
toolsandhandoffsinAgent.clone()are shallow-copied:Includes:
Agent.clone()