Skip to content

Pin MCP runtimes to model steps - #30101

Merged
jif-oai merged 6 commits into
mainfrom
jif/pin-mcp-runtime-to-model-steps
Jun 25, 2026
Merged

Pin MCP runtimes to model steps#30101
jif-oai merged 6 commits into
mainfrom
jif/pin-mcp-runtime-to-model-steps

Conversation

@jif-oai

@jif-oai jif-oai commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Why

An MCP refresh can replace the session's current manager while a model step is still running. The step must execute calls through the same manager whose tools it advertised.

Boundary

current session MCP runtime
          |
          | capture once for this model step
          v
StepContext.mcp
  - exact MCP config
  - exact connection manager
  - exact runtime environment context
pub struct McpRuntimeSnapshot {
    config: Arc<McpConfig>,
    manager: Arc<McpConnectionManager>,
    runtime_context: McpRuntimeContext,
}

Example

step A captures runtime A and advertises A's tools
refresh publishes runtime B
step A tool call -> runtime A
next step        -> runtime B

Capturing the snapshot is only an Arc clone. It does not restart MCPs or make an RPC.

What changes

  • Captures one MCP runtime in StepContext.
  • Uses it for tool planning, tool calls, resources, approvals, connector attribution, and elicitation.
  • Publishes replacement runtimes atomically.
  • Lets an old runtime live only while an in-flight step or request still holds its Arc.

Most of this diff is mechanical routing from the session-global manager to step_context.mcp; it does not introduce selected-plugin discovery yet.

What does not change

  • No plugin or extension migration.
  • No new MCP cache policy.
  • No environment file watching.
  • No client sharing between separate managers.

Stack

  1. Extension-owned World State sections.
  2. Project executor skills through World State.
  3. This PR: pin one MCP runtime to each model step.
  4. Project selected MCP/app/connector metadata by environment availability.
  5. One end-to-end integration scenario.
@jif-oai
jif-oai force-pushed the jif/extension-owned-selected-skills branch from 06c6eea to f55c074 Compare June 25, 2026 19:59
@jif-oai
jif-oai force-pushed the jif/pin-mcp-runtime-to-model-steps branch from ccd5e07 to 472f006 Compare June 25, 2026 19:59
@jif-oai jif-oai changed the title Pin MCP runtime to each model step Pin MCP runtimes to model steps Jun 25, 2026
@jif-oai
jif-oai marked this pull request as ready for review June 25, 2026 20:04
@jif-oai
jif-oai requested a review from a team as a code owner June 25, 2026 20:04

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

Copy link
Copy Markdown
Contributor

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: 472f006963

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

Comment thread codex-rs/core/src/session/step_context.rs
Comment thread codex-rs/core/src/codex_delegate.rs
Comment thread codex-rs/core/src/session/handlers.rs
Comment thread codex-rs/core/src/session/mcp.rs
@jif-oai
jif-oai force-pushed the jif/extension-owned-selected-skills branch from f55c074 to 04a50f4 Compare June 25, 2026 20:14
@jif-oai
jif-oai force-pushed the jif/pin-mcp-runtime-to-model-steps branch from 472f006 to ba82a6e Compare June 25, 2026 20:14
Comment thread codex-rs/app-server/src/request_processors/mcp_processor.rs Outdated
Comment thread codex-rs/core/tests/suite/mcp_refresh_cleanup.rs
Comment thread codex-rs/core/src/session/mcp_runtime.rs
Base automatically changed from jif/extension-owned-selected-skills to main June 25, 2026 23:13
@jif-oai
jif-oai force-pushed the jif/pin-mcp-runtime-to-model-steps branch from 0b03fc3 to 6aa2f3e Compare June 25, 2026 23:24
@jif-oai
jif-oai enabled auto-merge (squash) June 25, 2026 23:41
@jif-oai
jif-oai disabled auto-merge June 25, 2026 23:53
@jif-oai
jif-oai merged commit ee9e0f6 into main Jun 25, 2026
30 checks passed
@jif-oai
jif-oai deleted the jif/pin-mcp-runtime-to-model-steps branch June 25, 2026 23:53
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

2 participants