Skip to content

Guidance on using the same agent instance across multiple requests #1039

Open
@jaydeepk

Description

@jaydeepk

Hi

I'm implementing a web based chatbot using FastApi and OpenAI agents.
The agent is hooked up with an SSE MCP server.

self.agent = Agent(
      name="Assistant",
      instructions="Use the tools to interact with the API.",
      mcp_servers=[self.mcp_server],
  )

At present I maintain Agent in global state..so the same agent instance is used across requests.
So far I have not noticed any issues in terms of reusing the same agent instance.
But is this a good idea?
Are there any potential issues I need to be wary of?
I'm in an early stage of exploring this space, so would appreciate any guidance on this.

Thanks
Jaydeep

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about using the SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions