Skip to content

Handoff initialised with handoff method causes closure bug #2087

@mukul-atomicwork

Description

@mukul-atomicwork

Please read this first

  • Have you read the docs?Agents SDK docs
  • Have you searched for related issues? Others may have faced similar issues.

Describe the bug

A clear and concise description of what the bug is.

Debug information

  • Agents SDK version: 0.5.1
  • Python version: 3.11.14

Repro steps

Create a list of handoff with diff agent and diff on_handoff.
Since in handoff we pass the agent from outer function to the inner function and passing it around. But because of the below issue even though there are different Handoff Objects they are overwriting whatever value was set in the previous run.
https://www.reddit.com/r/ProgrammingLanguages/comments/bxxx7x/python_closures_are_capturing_by_reference_should/#:~:text=Languages%20with%20closures%20always%20capture,used
Ideally provide a minimal python script that can be run to reproduce the bug.

Expected behavior

A clear and concise description of what you expected to happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-more-infoWaiting for a reply/more info from the author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions