Skip to content

Add per-chat leases for shared MCP connections - #57978

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/f4c8b606cb98b5697acab1c515e992ff80ec8425
Oct 29, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/f4c8b606cb98b5697acab1c515e992ff80ec8425

Conversation

@copyberry

@copyberry copyberry Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Add per-chat leases for shared MCP connections

What changed

Negotiate the codex/connection-lease extension for pooled stdio connections. For servers that advertise it, open a unique lease per chat and attach its host-owned ID to tool calls and resource reads via codex/connectionLease, overriding caller-supplied lease metadata.

When a chat releases its lease, write cancellations for pending requests before sending codex/connection/release. Preserve open-before-release ordering across startup timeouts, bound unload waits, and remove connections from the pool when lease cleanup fails or times out. Servers without the extension retain existing behavior.

Testing

Add coverage for cancellation-before-release ordering, late open acknowledgements, and lease drops outside the runtime. Extend app-server sharing tests to verify distinct chat leases, metadata replacement, release on unload, and continued use by another chat.

## What changed

Negotiate the `codex/connection-lease` extension for pooled stdio connections. For servers that advertise it, open a unique lease per chat and attach its host-owned ID to tool calls and resource reads via `codex/connectionLease`, overriding caller-supplied lease metadata.

When a chat releases its lease, write cancellations for pending requests before sending `codex/connection/release`. Preserve open-before-release ordering across startup timeouts, bound unload waits, and remove connections from the pool when lease cleanup fails or times out. Servers without the extension retain existing behavior.

## Testing

Add coverage for cancellation-before-release ordering, late open acknowledgements, and lease drops outside the runtime. Extend app-server sharing tests to verify distinct chat leases, metadata replacement, release on unload, and continued use by another chat.

GitOrigin-RevId: f4c8b606cb98b5697acab1c515e992ff80ec8425
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/f4c8b606cb98b5697acab1c515e992ff80ec8425 branch from 6c720ce to 8fdf647 Compare October 29, 2026 03:48
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-29T03:48:03.784337Z 6c720ce PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@copyberry
copyberry Bot merged commit 8fdf647 into main Oct 29, 2026
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/f4c8b606cb98b5697acab1c515e992ff80ec8425 branch October 29, 2026 03:48
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 29, 2026

This branch was previously deployed

1 inactive deployment
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants