fix: serialize streamable-http MCP requests per session#2682
Conversation
Co-authored-by: Codex <[email protected]>
|
@codex please review |
There was a problem hiding this comment.
💡 Codex Review
openai-agents-python/src/agents/mcp/server.py
Lines 685 to 694 in 26d2fd0
MCPServerStreamableHttp enables _serialize_session_requests, but list_prompts/get_prompt bypass _maybe_serialize_request and call ClientSession directly. That leaves prompt RPCs able to run concurrently with tool RPCs, so one failed request can still cancel an in-flight sibling on the shared streamable-HTTP transport.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Route prompt RPCs through the existing request lock and add regression coverage for list_prompts/get_prompt so prompt calls cannot cancel in-flight tool calls on streamable HTTP.\n\nCo-authored-by: Codex <[email protected]>
|
@codex please review |
|
Codex Review: Didn't find any major issues. 🎉 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Serialize request RPCs per
MCPServerStreamableHttpsession so one failed request cannot cancel sibling in-flight requests that share the same underlying streamable-HTTP transport task group.This is a narrow SDK-side workaround for the shared transport behavior in the
mcpclient dependency. It keeps the public API unchanged and only affects howMCPServerStreamableHttpschedules requests on a single connected session.Test plan
make syncmake formatmake lintmake typecheckmake testsuv run python -m pytest tests/mcp/test_client_session_retries.py -k 'serialized_session_requests_prevent_sibling_cancellation or test_call_tool_retries_until_success' -qIssue number
N/A
Checks
make lintandmake format