diff --git a/codex-rs/core/src/codex_apps_file_download.rs b/codex-rs/core/src/codex_apps_file_download.rs index 09b019446c..164a79a107 100644 --- a/codex-rs/core/src/codex_apps_file_download.rs +++ b/codex-rs/core/src/codex_apps_file_download.rs @@ -36,26 +36,19 @@ fn codex_apps_download_base_url(turn_context: &TurnContext) -> &str { fn should_materialize_codex_apps_file_download( server: &str, codex_apps_meta: Option<&JsonMap>, - result_meta: Option<&JsonMap>, ) -> bool { if server != codex_mcp::CODEX_APPS_MCP_SERVER_NAME { return false; } - codex_apps_materialize_file_download_flag(result_meta) - .or_else(|| codex_apps_materialize_file_download_flag(codex_apps_meta)) - == Some(true) -} + let Some(codex_apps_meta) = codex_apps_meta else { + return false; + }; -fn codex_apps_materialize_file_download_flag( - codex_apps_meta: Option<&JsonMap>, -) -> Option { codex_apps_meta - .and_then(|codex_apps_meta| { - codex_apps_meta - .get(CODEX_APPS_META_MATERIALIZE_FILE_DOWNLOAD_KEY) - .and_then(JsonValue::as_bool) - }) + .get(CODEX_APPS_META_MATERIALIZE_FILE_DOWNLOAD_KEY) + .and_then(JsonValue::as_bool) + == Some(true) } pub(crate) async fn maybe_materialize_codex_apps_file_download_result( @@ -65,8 +58,7 @@ pub(crate) async fn maybe_materialize_codex_apps_file_download_result( codex_apps_meta: Option<&JsonMap>, mut result: CallToolResult, ) -> CallToolResult { - let result_meta = result.meta.as_ref().and_then(JsonValue::as_object); - if !should_materialize_codex_apps_file_download(server, codex_apps_meta, result_meta) + if !should_materialize_codex_apps_file_download(server, codex_apps_meta) || result.is_error == Some(true) { return result; @@ -256,19 +248,6 @@ mod tests { use wiremock::matchers::method; use wiremock::matchers::path; - #[test] - fn should_materialize_codex_apps_file_download_reads_result_meta() { - let result_meta = serde_json::json!({ - CODEX_APPS_META_MATERIALIZE_FILE_DOWNLOAD_KEY: true, - }); - - assert!(should_materialize_codex_apps_file_download( - codex_mcp::CODEX_APPS_MCP_SERVER_NAME, - /*codex_apps_meta*/ None, - result_meta.as_object(), - )); - } - #[tokio::test] async fn codex_apps_file_download_materialization_adds_local_path_for_marked_tools() { let server = MockServer::start().await;