Symptom
After the first agent.run(), the httpx.AsyncClient passed to MCPServerStreamableHTTP is closed. The next run raises RuntimeError: Cannot reopen a client instance, once it has been closed.
Evidence what you'll see
- The report prints
http_client.is_closedand it isTrueafter the first run. - The client is created by the caller and passed as
http_client.
Why it happens
The server closed the caller-supplied client when the request finished. The pull request title is not to close a custom httpx client passed to MCPServerHTTP. The pull request body does not give a diff.
Affected versions
Pydantic AI 0.6.2, Python 3.13. The linked issue does not name an operating system.
Fix steps
0 of 1 done
Your check marks stay in this browser only.
How to check it worked
- Run the agent twice with the same
http_clientand confirmhttp_client.is_closedis stillFalseafter the first run.
If it still fails
- The linked issue does not describe
Cannot reopen a client instanceonv1.23.0. On0.6.2the secondagent.run()raises it.
Sources and credit
Summarized in our own words from these public reports. Credit goes to their authors.
Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change
Hit an error we don't cover? Submit it