mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
Remove cumulative MCP attribution from requests and rollouts (#62589)
## What changed Stop collecting cumulative MCP tool attribution, sending it in Responses API request metadata, and writing it to rollout checkpoints. Use `model_search_state` for search provider history in new rollouts. When reading older rollouts, decode `mcp_attribution` only to determine whether Search MCP may have been used. Treat malformed or error attribution as possible Search MCP use so native search fallback stays disabled. ## Testing Add a history test that distinguishes legacy Search MCP use, an explicit record of no use, and missing attribution. GitOrigin-RevId: a145b5b6b7d2f423d989af10623ef21120f49d4d
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
//! `schemars`) so they can be embedded in Codex's own protocol structures.
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use serde::Deserializer;
|
||||
use serde::Serialize;
|
||||
use std::collections::HashMap;
|
||||
use ts_rs::TS;
|
||||
@@ -64,80 +63,6 @@ pub fn is_node_repl_backed_tool(name: &str, namespace: Option<&str>) -> bool {
|
||||
.is_some_and(|(server, _)| is_node_repl_backed_server(server))
|
||||
}
|
||||
|
||||
/// Producer-reported completeness of the thread's MCP tools/call attribution.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum McpAttributionStatus {
|
||||
#[default]
|
||||
None,
|
||||
Complete,
|
||||
AttributionError,
|
||||
}
|
||||
|
||||
/// Bounded diagnostics for an attribution error, never a policy decision.
|
||||
///
|
||||
/// Recorder reasons identify the first observed error and survive checkpoints.
|
||||
/// Payload reasons describe a request-serialization fallback and are not checkpointed.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[non_exhaustive]
|
||||
pub enum McpAttributionErrorReason {
|
||||
HistoryMissingCheckpoint,
|
||||
CheckpointInvalid,
|
||||
CheckpointSourceConflict,
|
||||
SourceInvalid,
|
||||
RecorderPoisoned,
|
||||
/// An earlier error checkpoint did not retain its cause.
|
||||
RestoredErrorUnknown,
|
||||
PayloadTooLarge,
|
||||
SerializationFailed,
|
||||
#[serde(other)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// One source and the first runtime turn in which Codex recorded it.
|
||||
///
|
||||
/// Server and tool names are retained when no stable identifier is available;
|
||||
/// they are not guaranteed to be globally unique or independently authenticated.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct McpAttributionSource {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub connector_id: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub plugin_id: Option<String>,
|
||||
pub server_name: String,
|
||||
pub tool_name: String,
|
||||
pub first_turn_id: String,
|
||||
}
|
||||
|
||||
/// Cumulative, model-invisible attribution reported on Responses API requests.
|
||||
/// This is provenance data, not a training-eligibility decision or attestation.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct McpAttribution {
|
||||
pub status: McpAttributionStatus,
|
||||
/// First observed attribution error, absent for non-error states.
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
deserialize_with = "deserialize_mcp_attribution_error_reason"
|
||||
)]
|
||||
pub error_reason: Option<McpAttributionErrorReason>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub sources: Vec<McpAttributionSource>,
|
||||
}
|
||||
|
||||
fn deserialize_mcp_attribution_error_reason<'de, D>(
|
||||
deserializer: D,
|
||||
) -> Result<Option<McpAttributionErrorReason>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let value = serde_json::Value::deserialize(deserializer)?;
|
||||
Ok(serde_json::from_value(value).ok())
|
||||
}
|
||||
|
||||
/// Bounded app-resource provenance retained across a compaction checkpoint.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct McpResourceOriginCheckpoint {
|
||||
|
||||
Reference in New Issue
Block a user