Is it bad practice to create_agent all the time?

hi @MartinYTSo

try this:

# Create the context manager
_checkpointer_cm = PostgresSaver.from_conn_string(os.getenv("POSTGRES_URI"))
# Enter it once and keep the real PostgresSaver
checkpointer = _checkpointer_cm.__enter__()
checkpointer.setup()  # once on startup
# ...
agent = create_agent("gpt-4o-mini", checkpointer=checkpointer)