Files
codex/codex-rs/rmcp-client/src/service_error.rs
T
yitaoh-oai 4360c5f813 Remove model-selected Search MCP routing (#62808)
## What changed

Use the turn's effective `web_search` mode for standalone and hosted
web search. Remove model-selected Search MCP discovery, fallback, and
provider tracking across thread resumes.

Remove `web_search_provider` from model metadata, the
`tools.client_search_provider` hint from configuration, and the
`hosted_search_policy` feature flag. Update the app-server schemas and
generated SDK types to match.

GitOrigin-RevId: 59e3371f4a43d532a484db52d5998f6770292028
2026-11-20 17:46:32 +00:00

49 lines
1.8 KiB
Rust

//! Access structured MCP errors without dropping their original protocol data.
use anyhow::Error;
use rmcp::ErrorData;
use rmcp::service::ServiceError;
use std::time::Duration;
use crate::rmcp_client::ClientOperationError;
/// Returns the server's structured protocol error, including its original data.
pub fn mcp_error(error: &Error) -> Option<&ErrorData> {
let ClientOperationError::Service(ServiceError::McpError(error)) = error.downcast_ref()? else {
return None;
};
Some(error)
}
/// Preserves a request deadline as a typed error for caller-side telemetry.
pub fn request_timeout_error(label: &str, duration: Duration) -> Error {
ClientOperationError::Timeout {
label: label.to_string(),
duration,
}
.into()
}
/// Returns a bounded caller-side failure category without parsing error text.
pub fn request_error_code(error: &Error) -> Option<&'static str> {
let error = error.downcast_ref::<ClientOperationError>()?;
Some(match error {
ClientOperationError::Timeout { .. } => "request_timeout",
ClientOperationError::Service(error) => match error {
ServiceError::Timeout { .. } => "request_timeout",
ServiceError::TransportClosed => "transport_closed",
ServiceError::TransportSend(_) => "transport_error",
ServiceError::McpError(_) => "protocol_error",
ServiceError::UnexpectedResponse => "unexpected_response",
ServiceError::Cancelled { .. } => "cancelled",
ServiceError::SubscriptionLagged { .. } => "subscription_lagged",
ServiceError::InputRequiredRoundsExceeded { .. } => "input_required_rounds_exceeded",
_ => return None,
},
})
}
#[cfg(test)]
#[path = "service_error_tests.rs"]
mod tests;