Filter media from function call output notifications (#41427)

## What changed

Strip inline image and audio content from function call output thread items when
filtering app-server notifications. Preserve text and encrypted content, and
leave text-only function call outputs unchanged.

GitOrigin-RevId: ca3ad70e843aafbed49c693aa8963bea86cf95dc
This commit is contained in:
Krish Chainani
2026-08-28 21:16:28 +00:00
committed by copyberry
parent f9cdc90c2c
commit 2008d27e98

View File

@@ -3,6 +3,7 @@ use codex_app_server_protocol::ServerNotification;
use codex_app_server_protocol::ThreadItem;
use codex_app_server_protocol::UserInput;
use codex_protocol::models::ContentItem;
use codex_protocol::models::FunctionCallOutputBody;
use codex_protocol::models::FunctionCallOutputContentItem;
use codex_protocol::models::ResponseItem;
@@ -108,6 +109,8 @@ pub(crate) fn without_notification_media(notification: ServerNotification) -> Se
| ServerNotification::ContextCompacted(_)
| ServerNotification::ModelRerouted(_)
| ServerNotification::ModelVerification(_)
| ServerNotification::AuthRecoveryStarted(_)
| ServerNotification::AuthRecoveryCompleted(_)
| ServerNotification::TurnModerationMetadata(_)
| ServerNotification::ModelSafetyBufferingUpdated(_)
| ServerNotification::Warning(_)
@@ -155,6 +158,17 @@ fn without_thread_item_media(mut item: ThreadItem) -> ThreadItem {
DynamicToolCallOutputContentItem::InputText { .. } => true,
});
}
ThreadItem::FunctionCallOutput {
output: FunctionCallOutputBody::ContentItems(items),
..
} => {
items.retain(|item| match item {
FunctionCallOutputContentItem::InputImage { .. }
| FunctionCallOutputContentItem::InputAudio { .. } => false,
FunctionCallOutputContentItem::InputText { .. }
| FunctionCallOutputContentItem::EncryptedContent { .. } => true,
});
}
ThreadItem::McpToolCall {
result: Some(result),
..
@@ -176,6 +190,10 @@ fn without_thread_item_media(mut item: ThreadItem) -> ThreadItem {
| ThreadItem::AgentMessage { .. }
| ThreadItem::Plan { .. }
| ThreadItem::Reasoning { .. }
| ThreadItem::FunctionCallOutput {
output: FunctionCallOutputBody::Text(_),
..
}
| ThreadItem::CommandExecution { .. }
| ThreadItem::FileChange { .. }
| ThreadItem::McpToolCall { result: None, .. }