If you're plugging a FastMCP server into OpenAI's Responses API and your sessions keep dying with Session has been terminated, the fix is one flag: stateless_http=True when you instantiate FastMCP(...). OpenAI sends a DELETE after each call without recreating the session, so anything stateful gets terminated between requests.
The full post covers the JSON-RPC error you'll actually see, the minimal server change to make it work, and the caveats — session state and certain bi-directional streaming patterns drop out in stateless mode. Worth a quick read if you're hitting the same one-call-then-broken behaviour.
Originally published at andreasbergstrom.dev — read the full post there.
Top comments (1)
Thanks for this tip! This is more useful to me as a debug tool as my code with errors now properly outputs error messages rather than just "Session Terminated" in the OpenAI Prompt Logs.