Skip to content

Retry transient streamable-http MCP tool failures on isolated session#2703

Merged
seratch merged 7 commits intomainfrom
dev/elainegan/mcp-streamable-http-isolated-retry-clean
Mar 18, 2026
Merged

Retry transient streamable-http MCP tool failures on isolated session#2703
seratch merged 7 commits intomainfrom
dev/elainegan/mcp-streamable-http-isolated-retry-clean

Conversation

@elainegan-openai
Copy link
Contributor

@elainegan-openai elainegan-openai commented Mar 17, 2026

Summary

  • retry transient streamable-http MCP call_tool() failures on a fresh isolated session
  • keep the healthy-path shared session unchanged
  • add transport-focused regression coverage for cancelled shared-session requests, 5xx retries, 4xx non-retries, and preserved outer cancellation

Why

We reproduced a shared-runtime MCP failure mode where one failed streamable-http request can cancel a sibling in-flight request on the same session.

This PR only addresses the transport slice: preserve healthy-path parallelism, but isolate a request onto a fresh session when the shared-session request hits a transient failure.

Validation

  • ruff check src/agents/mcp/server.py tests/mcp/test_client_session_retries.py
  • uv run pytest -q tests/mcp/test_client_session_retries.py
  • timeout 30 uv run mypy src/agents/mcp/server.py tests/mcp/test_client_session_retries.py

@elainegan-openai elainegan-openai marked this pull request as ready for review March 17, 2026 23:29
@elainegan-openai
Copy link
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ 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".

Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you resolve the conflicts?

@seratch seratch marked this pull request as draft March 17, 2026 23:49
@elainegan-openai elainegan-openai marked this pull request as ready for review March 17, 2026 23:52
Keep the streamable-http isolated retry change and preserve the newer serialized-request regression coverage added on main.

Co-authored-by: Codex <noreply@openai.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4165158eaf

ℹ️ 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 the shared-session streamable HTTP call_tool path back through request serialization so it stays synchronized with list_prompts and get_prompt. Keep the isolated retry behavior and add regression coverage for both direct cancellation retry and prompt/tool serialization.

Co-authored-by: Codex <noreply@openai.com>
@elainegan-openai
Copy link
Contributor Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d6ebbf702f

ℹ️ 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".

Count isolated-session fallback against max_retry_attempts, avoid retrying mixed exception groups that include non-transient failures, and add regression coverage for zero-budget and mixed-group behavior.

Co-authored-by: Codex <noreply@openai.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f0a683774

ℹ️ 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".

Do not wrap outer-task cancellation when an isolated-session fallback is already in progress. Add a regression test that cancels the caller while the isolated retry is blocked.

Co-authored-by: Codex <noreply@openai.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ca71ef970

ℹ️ 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".

Co-authored-by: Codex <noreply@openai.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a075f129d4

ℹ️ 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".

Co-authored-by: Codex <noreply@openai.com>
@seratch seratch added this to the 0.12.x milestone Mar 18, 2026
@seratch seratch merged commit c4c1772 into main Mar 18, 2026
9 checks passed
@seratch seratch deleted the dev/elainegan/mcp-streamable-http-isolated-retry-clean branch March 18, 2026 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants