Skip to content

Is the same agent instance needed #1290

@jaydeepk

Description

@jaydeepk

Hi
I'm looking at implementing session support in agents.
Based on the examples provided, it looks like the same agent instance is used across calls.

First turn
result = await Runner.run(
    agent,
    "What city is the Golden Gate Bridge in?",
    session=session
)
print(result.final_output)  # "San Francisco"

Second turn - agent automatically remembers previous context
result = await Runner.run(
    agent,
    "What state is it in?",
    session=session
)

Do we need to ensure that the same agent instance is used everytime?
Would this still work if a different agent instance is created in the second turn (with the same session) ?
Any recommendations / guidance.

Thanks
Jaydeep

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions