Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

McpError when run-mcp-python code sandbox handles concurrent requests #8

Open
@ivo-1

Description

Initial Checks

Description

We are facing issues with the run-mcp-python code sandbox on concurrent requests.

Context:

  • we are using pydantic_graph
  • we are using temporal to execute the nodes as activities
  • we are running the mcp-run-python server with the streamable_http protocol
  • we observe no issues when the code sandbox only has to handle one request at a time
  • we are wrapping the agent.run() call like so and passing in the run-mcp-python server as a remote MCPServerStreamableHTTP with a read timeout of 60s:
async with agent:
 return await agent.run(toolsets=mcp_servers)

Issues:

  1. The run-mcp-python server seems to have issues with handling concurrent requests (starts happening at 2 concurrent requests). It reliably times out after 60s. I'm not sure what the expectation is regarding handling concurrent requests but my understanding was that this is handled.
  2. More notably: This results in failures of agent.run() with 2 sub-cases we observe
  • The tool call itself times out resulting in a ToolRetryError. This makes sense and is fine.

  • Other (parallel) tool calls that are successful still lead to errors in agent.run() -- more specifically the GET and POST requests to /mcp timeout which seems to lead to that. This results in McpError for agent.run() and bubbles up to a unhandled errors in a TaskGroup (1 sub-exception) in the top-level BaseNode.run(). I've attached a screenshot of our traces in logfire that illustrates this case. Unfortunately I can't share a link to the trace here.

Image

Apologies for not having a MRE at hand and of course happy to work on providing one if there is no obvious bug that you already are aware of.

Python, Pydantic AI & LLM client version

Python: 3.13.5
Pydantic: 0.7.5
LLM Client: OpenRouter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /