openai/codex · error · anyhow::Error

tool call rejected because the catalog changed after

Error message

tool call rejected because the catalog changed after `{}/{tool_name}` was prepared

What it means

MCP tool-call staleness guard in call_with_preparation: between preparing the tool call (captured arguments) and executing it, the tool catalog was refreshed and the tool no longer matches its preparation, so the call is rejected rather than run against stale metadata.

Solutions

  1. Retry the tool call so it prepares against the new catalog
  2. Avoid mutating the MCP server config mid-conversation
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at codex-rs/codex-mcp/src/binding.rs:295 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/90962c3cc8ab9913. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/codex-mcp/src/binding.rs:295

    pub async fn call_with_preparation<F, Fut>(
        &self,
        requested_timeout: Option<Duration>,
        prepare: F,
    ) -> Result<CallToolResult>
    where
        F: FnOnce() -> Fut,
        Fut: Future<Output = Result<(Option<JsonValue>, Option<JsonValue>)>>,
    {
        let effective_timeout = match (self.client.tool_timeout, requested_timeout) {
            (Some(server_timeout), Some(requested_timeout)) => {
                Some(server_timeout.min(requested_timeout))
            }
            (server_timeout, requested_timeout) => server_timeout.or(requested_timeout),
        };
        let tool_name = self.tool_info.tool.name.to_string();
        let current_revision = self.catalog_revision_source.read().await;
        if *current_revision != self.catalog_revision {
            return Err(anyhow::anyhow!(
                "tool call rejected because the catalog changed after `{}/{tool_name}` was prepared",
                self.server_name
            ));
        }
        let (arguments, meta) = prepare().await?;
        let result = self
            .client
            .client
            .call_tool(tool_name.clone(), arguments, meta, effective_timeout)
            .await
            .with_context(|| format!("tool call failed for `{}/{tool_name}`", self.server_name))?;
        drop(current_revision);
        Ok(call_tool_result_from_rmcp(result))
    }
}

pub(crate) fn call_tool_result_from_rmcp(result: rmcp::model::CallToolResult) -> CallToolResult {
    let content = result

View on GitHub (pinned to 339751715c)