mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
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:
1 parent
166658a34a
commit
03edf16f0b
36 files changed
+390
-76
No files matched your search
@@ -20,6 +20,7 @@ use codex_tools::ToolCall as ExtensionToolCall;
|
||||
use codex_tools::ToolExecutor;
|
||||
use codex_tools::ToolName;
|
||||
use codex_tools::ToolSpec;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
@@ -33,6 +34,36 @@ pub struct ToolCall {
|
||||
pub tool_name: ToolName,
|
||||
pub call_id: String,
|
||||
pub payload: ToolPayload,
|
||||
pub encrypted_function_args: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
impl ToolCall {
|
||||
pub(crate) fn direct_source(&self) -> ToolCallSource {
|
||||
if self.tool_name.namespace.as_deref() == Some("collaboration")
|
||||
&& matches!(
|
||||
self.tool_name.name.as_str(),
|
||||
"spawn_agent" | "send_message" | "followup_task"
|
||||
)
|
||||
&& self
|
||||
.encrypted_function_args
|
||||
.as_ref()
|
||||
.is_some_and(Vec::is_empty)
|
||||
{
|
||||
ToolCallSource::DirectPlaintextMessage
|
||||
} else {
|
||||
ToolCallSource::Direct
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn tool_log_payload<'a>(
|
||||
payload: &'a ToolPayload,
|
||||
source: &ToolCallSource,
|
||||
) -> Cow<'a, str> {
|
||||
if matches!(source, ToolCallSource::DirectPlaintextMessage) {
|
||||
return Cow::Borrowed("[plaintext arguments]");
|
||||
}
|
||||
payload.log_payload()
|
||||
}
|
||||
|
||||
pub struct ToolRouter {
|
||||
@@ -131,6 +162,7 @@ impl ToolRouter {
|
||||
name,
|
||||
namespace,
|
||||
arguments,
|
||||
encrypted_function_args,
|
||||
call_id,
|
||||
..
|
||||
} => {
|
||||
@@ -139,6 +171,7 @@ impl ToolRouter {
|
||||
tool_name,
|
||||
call_id,
|
||||
payload: ToolPayload::Function { arguments },
|
||||
encrypted_function_args,
|
||||
}))
|
||||
}
|
||||
ResponseItem::ToolSearchCall {
|
||||
@@ -157,6 +190,7 @@ impl ToolRouter {
|
||||
tool_name: ToolName::plain("tool_search"),
|
||||
call_id,
|
||||
payload: ToolPayload::ToolSearch { arguments },
|
||||
encrypted_function_args: None,
|
||||
}))
|
||||
}
|
||||
ResponseItem::ToolSearchCall { .. } => Ok(None),
|
||||
@@ -170,6 +204,7 @@ impl ToolRouter {
|
||||
tool_name: ToolName::new(namespace, name),
|
||||
call_id,
|
||||
payload: ToolPayload::Custom { input },
|
||||
encrypted_function_args: None,
|
||||
})),
|
||||
_ => Ok(None),
|
||||
}
|
||||
@@ -237,6 +272,7 @@ impl ToolRouter {
|
||||
tool_name,
|
||||
call_id,
|
||||
payload,
|
||||
..
|
||||
} = call;
|
||||
|
||||
// Keep the legacy ToolInvocation.turn field tied to the same request state until handlers migrate.
|
||||
|
||||
Reference in new issue
Block a user