Support plaintext collaboration tool messages (#35845)

## What changed

- Preserve `encrypted_function_args` on function calls so an empty list can mark plaintext collaboration arguments across request replay.
- Deliver `spawn_agent`, `send_message`, and `followup_task` payloads as structured plaintext agent messages when that marker is present; retain encrypted delivery otherwise.
- Redact plaintext collaboration arguments from tool and communication logs, and omit the metadata when sending requests to non-OpenAI providers.

## Testing

- Cover serialization of empty encrypted-argument metadata and plaintext versus encrypted subagent message delivery.
- Verify plaintext tool arguments are redacted and provider-specific metadata is removed from non-OpenAI requests.

GitOrigin-RevId: 64db98ff0b61a3af2f04ed609292363f2e2362a8
This commit is contained in:
jif authored and copyberry committed 2026-07-28 23:49:37 +00:00
1 parent 166658a34a
commit 03edf16f0b
36 files changed
+390 -76

No files matched your search

+26
View File
@@ -37,9 +37,25 @@ use super::ToolCallSource;
use super::ToolRouter;
use super::ToolRouterParams;
use super::extension_tool_executors;
use super::tool_log_payload;
struct ExtensionEchoContributor;
#[test]
fn tool_log_payload_redacts_plaintext_multi_agent_messages() {
let payload = ToolPayload::Function {
arguments: json!({"target": "/root/worker", "message": "secret message"}).to_string(),
};
assert_eq!(
tool_log_payload(&payload, &ToolCallSource::DirectPlaintextMessage),
"[plaintext arguments]"
);
assert_eq!(
tool_log_payload(&payload, &ToolCallSource::Direct),
payload.log_payload()
);
}
impl codex_extension_api::ToolContributor for ExtensionEchoContributor {
fn tools(
&self,
@@ -135,6 +151,7 @@ async fn parallel_support_does_not_match_namespaced_local_tool_names() -> anyhow
payload: ToolPayload::Function {
arguments: "{}".to_string(),
},
encrypted_function_args: None,
})
})
.expect("test session should expose a parallel shell-like tool");
@@ -145,6 +162,7 @@ async fn parallel_support_does_not_match_namespaced_local_tool_names() -> anyhow
payload: ToolPayload::Function {
arguments: "{}".to_string(),
},
encrypted_function_args: None,
}));
Ok(())
@@ -159,6 +177,7 @@ async fn build_tool_call_uses_namespace_for_registry_name() -> anyhow::Result<()
name: tool_name.clone(),
namespace: Some("mcp__codex_apps__calendar".to_string()),
arguments: "{}".to_string(),
encrypted_function_args: Some(Vec::new()),
call_id: "call-namespace".to_string(),
internal_chat_message_metadata_passthrough: None,
})?
@@ -169,6 +188,8 @@ async fn build_tool_call_uses_namespace_for_registry_name() -> anyhow::Result<()
ToolName::namespaced("mcp__codex_apps__calendar", tool_name)
);
assert_eq!(call.call_id, "call-namespace");
assert_eq!(call.encrypted_function_args, Some(Vec::new()));
assert_eq!(call.direct_source(), ToolCallSource::Direct);
match call.payload {
ToolPayload::Function { arguments } => {
assert_eq!(arguments, "{}");
@@ -202,6 +223,7 @@ async fn build_custom_tool_call_uses_namespace_for_registry_name() -> anyhow::Re
payload: ToolPayload::Custom {
input: "print('hello')".to_string(),
},
encrypted_function_args: None,
}
);
@@ -246,6 +268,7 @@ async fn mcp_parallel_support_uses_handler_data() -> anyhow::Result<()> {
payload: ToolPayload::Function {
arguments: "{}".to_string(),
},
encrypted_function_args: None,
};
assert!(router.tool_supports_parallel(&call));
@@ -255,6 +278,7 @@ async fn mcp_parallel_support_uses_handler_data() -> anyhow::Result<()> {
payload: ToolPayload::Function {
arguments: "{}".to_string(),
},
encrypted_function_args: None,
};
assert!(!router.tool_supports_parallel(&different_server_call));
@@ -286,6 +310,7 @@ async fn tools_without_handlers_do_not_support_parallel() -> anyhow::Result<()>
payload: ToolPayload::Function {
arguments: "{}".to_string(),
},
encrypted_function_args: None,
}));
Ok(())
@@ -438,6 +463,7 @@ async fn extension_tool_executors_are_model_visible_and_dispatchable() -> anyhow
namespace: Some("extension/".to_string()),
arguments: json!({ "message": "hello" }).to_string(),
call_id: "call-extension".to_string(),
encrypted_function_args: None,
internal_chat_message_metadata_passthrough: None,
})?
.expect("function_call should produce a tool call");