{"record":{"id":"90962c3cc8ab9913","repo":"openai/codex","slug":"tool-call-rejected-because-the-catalog-changed-aft","errorCode":null,"errorMessage":"tool call rejected because the catalog changed after `{}/{tool_name}` was prepared","messagePattern":"tool call rejected because the catalog changed after `(.+?)/(.+?)` was prepared","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/codex-mcp/src/binding.rs","lineNumber":295,"sourceCode":"    pub async fn call_with_preparation<F, Fut>(\n        &self,\n        requested_timeout: Option<Duration>,\n        prepare: F,\n    ) -> Result<CallToolResult>\n    where\n        F: FnOnce() -> Fut,\n        Fut: Future<Output = Result<(Option<JsonValue>, Option<JsonValue>)>>,\n    {\n        let effective_timeout = match (self.client.tool_timeout, requested_timeout) {\n            (Some(server_timeout), Some(requested_timeout)) => {\n                Some(server_timeout.min(requested_timeout))\n            }\n            (server_timeout, requested_timeout) => server_timeout.or(requested_timeout),\n        };\n        let tool_name = self.tool_info.tool.name.to_string();\n        let current_revision = self.catalog_revision_source.read().await;\n        if *current_revision != self.catalog_revision {\n            return Err(anyhow::anyhow!(\n                \"tool call rejected because the catalog changed after `{}/{tool_name}` was prepared\",\n                self.server_name\n            ));\n        }\n        let (arguments, meta) = prepare().await?;\n        let result = self\n            .client\n            .client\n            .call_tool(tool_name.clone(), arguments, meta, effective_timeout)\n            .await\n            .with_context(|| format!(\"tool call failed for `{}/{tool_name}`\", self.server_name))?;\n        drop(current_revision);\n        Ok(call_tool_result_from_rmcp(result))\n    }\n}\n\npub(crate) fn call_tool_result_from_rmcp(result: rmcp::model::CallToolResult) -> CallToolResult {\n    let content = result","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/codex-mcp/src/binding.rs#L277-L313","documentation":"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.","triggerScenarios":"Thrown at codex-rs/codex-mcp/src/binding.rs:295 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the tool call so it prepares against the new catalog","Avoid mutating the MCP server config mid-conversation"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}