Add optional MCP disablement for prediction forks and samples (#55463)

## What changed

Add `experimentalDisablePredictionMcp` to `thread/fork` and `disableMcp` to `thread/sample`. Disable MCP servers when requested and the inherited history contains incremental tools on Responses Lite. The fork option requires `experimentalPredictionMode: true`.

Apply disablement through a thread-local policy that excludes configured MCP servers and runtime contributions, including after MCP refresh. Preserve the inherited history prefix and append tool-removal instructions without changing the parent's tools.

## Testing

Add coverage for prediction forks with legacy and paginated history, flag validation, conditional disablement, MCP refresh, and sample/fork request parity. Add a request-history snapshot covering preserved history, tool removal across child turns, and unchanged parent tools.

GitOrigin-RevId: e31d602480e6550ed130d8152f538b8668280fa0
This commit is contained in:
liame-oai
2026-10-20 05:25:43 +00:00
committed by copyberry
parent 18795fc125
commit 014489466a
12 changed files with 495 additions and 18 deletions
@@ -553,6 +553,12 @@ pub struct ThreadForkParams {
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub experimental_prediction_mode: bool,
/// Disable MCP servers in prediction mode when the inherited window uses incremental tools on Responses Lite.
/// Requires `experimentalPredictionMode: true`.
#[experimental("thread/fork.experimentalDisablePredictionMcp")]
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub experimental_disable_prediction_mcp: bool,
/// Optional last turn id to fork through, inclusive.
///
/// When specified, turns after `last_turn_id` are omitted from the fork.
@@ -20,6 +20,9 @@ pub struct ThreadSampleParams {
pub effort: Option<ReasoningEffort>,
#[ts(optional = nullable)]
pub turn_trigger: Option<String>,
/// Disable MCP servers when the inherited window uses incremental tools on Responses Lite.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub disable_mcp: bool,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]