Skip to content

Add a config option to select plaintext delivery for Multi-Agent V2 task messages #46939

Open

Description

@jerryan999

What variant of Codex are you using?

CLI (codex-cli 0.155.1) on macOS. The tool schemas are shared, so the same behaviour shows up in the app and the IDE extension.

What feature would you like to see?

Multi-Agent V2 marks the message parameter of all three collaboration tools as encrypted:

// codex-rs/core/src/tools/handlers/multi_agents_spec.rs (0.155.1)
// spawn_agent  -> line 633
("message".to_string(),
 JsonSchema::string(Some("Initial plain-text task for the new agent."))
     .with_encrypted()),
// send_message   -> line 198
// followup_task  -> line 231

The model then returns ciphertext, and the handler picks encrypted delivery unless the call is marked plaintext:

// codex-rs/core/src/tools/handlers/multi_agents_v2.rs:54
if matches!(source, crate::tools::context::ToolCallSource::DirectPlaintextMessage) {
    AgentMessage::Plaintext(message)
} else {
    AgentMessage::Encrypted(message)
}

The payload ends up in InterAgentCommunication::encrypted_content, with content left empty (codex-rs/protocol/src/protocol.rs:807).

Plaintext delivery is already reachable in the local orchestration path. #35845 taught the client to classify a collaboration call carrying encrypted_function_args: [] as ToolCallSource::DirectPlaintextMessage, which routes to AgentMessage::Plaintext. But that marker is produced by the server, so a user cannot choose it, and there is no config key either: MultiAgentV2ConfigToml (codex-rs/features/src/feature_configs.rs:255) and MultiAgentV2Config (codex-rs/core/src/config/mod.rs:1298) expose concurrency, wait timeouts, usage-hint text, tool namespace, metadata visibility and model-override settings — nothing about payload representation.

Please add a documented, supported knob, for example:

[features.multi_agent_v2]
message_delivery = "plaintext"   # "encrypted" (today's default) | "plaintext"

with these semantics:

  • encrypted (default) — unchanged behaviour for everyone who is happy with it, including first-party users.
  • plaintext — the collaboration payload is serialized as readable text so the parent tool call, the rollout, and the child-side AgentMessage all carry the task text, while the child still receives a structured InterAgentCommunication.
  • Selectable through config.toml, documented in the config reference, and usable without maintaining a fork.

Rationale for wanting the option rather than a behaviour change:

Additional information

Local observation that motivated this request: with a V2 catalog entry, parent rollouts record {"message":"gAAAA..."} for spawn_agent / send_message / followup_task and no readable copy survives; with a V1 catalog entry, the identical calls record the task text verbatim.

Related:

If maintainers consider this fully covered by #28058, closing it as a duplicate is fine. It is filed separately because #28058 is scoped as a regression report about auditability, whereas this is a request for a supported configuration option that lets users choose the delivery representation.

Activity

  1. added
    enhancement
    CLI
    subagent
    config
    custom-model
    on Sep 21, 2026
  2. chiuwill87 commented on Oct 1, 2026

    @chiuwill87

    Additional use case: validate the actual delegated task before native child creation.

    Released 0.159.3 still selects DirectPlaintextMessage only when a collaboration response carries explicit empty encrypted_function_args: router.rs. The inspected V2 configuration structs expose no delivery/plaintext setting. This agrees with the control gap described here.

    A metadata-only PreToolUse observation against 0.159.2 saw an opaque message with none of our task-contract labels. Explicit model/effort/task-name fields alone cannot validate the task scope, owned files, prohibited actions, verifier, or stop condition. This is an observed hook-boundary limitation, not an assertion about the private encryption implementation.

    Requested supported interface: either authenticated readable canonical task content at the pre-child enforcement boundary, bound to the actual native invocation, or equivalent trusted host-side validation before allocation. A second agent-supplied task copy or merely relabeling opaque bytes would not establish that binding.

    Acceptance: compliant bound task accepted; missing/unreadable/mismatched task denied before any child exists; child runtime identity verified separately. Mandatory validator failure denial is an additional dependency tracked in #41979.

    Could maintainers identify the supported producer/resolver owner and whether an existing transport control can provide this boundary? Source inspection and observed 0.159.3 worker metadata do not establish a working plaintext route; no 0.159.3 live plaintext proof is claimed.

  3. congee949 commented on Oct 3, 2026

    @congee949

    Additional real-provider evidence from Codex App's bundled CLI 0.159.2 on macOS. A V1 control successfully delegated research tasks from a ChatGPT-backed GPT lead to explicit Opus and Grok children; the corresponding encrypted V2 assignments were rejected before reaching the third-party providers.

    Tested topology and failure

    • Bundled CLI: 0.159.2; the separate standalone 0.160.0 was not used.
    • Gateway: official Magpie 0.1.702, commit 0a10be9cf9949b664897559293c6b43c52dc82ef.
    • Native openai provider through Magpie's /backend-api/codex.
    • Lead: group/auto-gpt-6-1-sol, actually served by a ChatGPT account as codex/gpt-6.1-sol.
    • Children: pure third-party Opus and Grok groups, explicitly selected with fork_turns:"none".

    On 2026-10-03, the two real V2 spawn_agent.message values were sealed gAAAAA… payloads. Magpie returned HTTP 400 before selecting a third-party provider. A GPT child control executed its task and produced a verified file. This isolates the failure to the assignment representation/provider boundary rather than the absence of a general dispatch mechanism.

    Magpie #619 already handles a different case: a destination group that contains a readable ChatGPT account. These pure third-party targets remain outside that repair.

    Real V1 control

    At 13:15:58–13:19:21 Asia/Shanghai on 2026-10-03, an isolated run of the same bundled 0.159.2:

    • copied the existing model catalog without removing entries;
    • set only the GPT lead group's multi_agent_version to "v1";
    • disabled the effective features.multi_agent_v2, enabled agents, and started a fresh root;
    • spawned two native V1 children with fork_context=false and explicit model overrides.
    Role Verified gateway provider/model
    Lead codex/gpt-6.1-sol
    Opus child cursor/claude-opus-5-5
    Grok child grok/grok-4.7-build-fast

    Both children actually read research material, wrote Chinese analyses with source references, ran Python, and generated unpredictable nonce/SHA256 artifacts. Both then completed a separate send_input follow-up. The lead read all artifacts; an independent checker recomputed all four hashes successfully. Persistent gateway records were filtered by the root and child thread IDs, so concurrent experiments were excluded. The third-party children were not silently replaced by GPT.

    Root and child metadata/turn contexts recorded V1, and the actual spawn task arguments were readable. This is a successful native task and follow-up control, not a synthetic empty-array marker.

    An additional run at 13:40:15–13:44:29 Asia/Shanghai verified actual online research: the Opus child executed gh api against official Codex PRs #26210/#35845, while the Grok child fetched Magpie #141 and this issue. Both produced analyses and source files; the lead waited and read them. Independent re-fetches matched the four objects' number/title/state/URL/update time/excerpt, and all source-file hashes matched. Gateway records confirmed the same three real provider/model identities.

    Research-output errors were retained separately: Opus wrote two incorrect PR update timestamps; Grok corrected two rejected floating-point tool arguments and over-inferred release status from an open issue body. Successful delivery and online execution do not certify every statement in the generated reports.

    Non-OpenAI V2 lead: partial control

    An additional isolated Opus-led V2 run successfully spawned Opus/Grok research children, received their automatic final results, and triggered a Grok follow-up. However, the Grok child did not expose send_message with the original catalog, so proactive messaging did not pass.

    A separate diagnostic changed only the two third-party catalog entries from missing multi_agent_version to "v2". The child received a readable task, but produced no new tool/artifact result before an SSE idle timeout; that attempt was stopped. It is retained as a failed diagnostic, not a working plaintext policy.

    Requested supported V2 path

    Please make the plaintext policy govern task production and classification, not only the receiving AgentMessage variant:

    1. A supported way for the lead to obtain readable parameters for spawn_agent, send_message, and followup_task, while preserving default encrypted OpenAI-to-OpenAI behavior.
    2. A documented legal entry point: a server-supported reserved collaboration schema/policy, or an officially supported ordinary-tool/Code Mode alternative. Removing encryption annotations from the reserved schema is not established as a deployable client fix.
    3. Consistent classification across direct calls, custom namespaces, Code Mode, streaming and replay, followed by provider-compatible message adaptation.
    4. Explicit rejection before child allocation or message enqueue when the representation is unreadable by the selected target.
    5. Separate acceptance for initial tasks, follow-ups, proactive messages, automatic final notifications, and actual provider/model identity.

    The inspected 0.159.2 path still requires explicit empty encrypted_function_args and the reserved collaboration namespace for DirectPlaintextMessage; Code Mode is not classified as plaintext there. Marking already sealed bytes as plaintext cannot recover the task.

    This request is cross-referenced with #34833 and #36376. The V1 workaround changes the collaboration protocol and tools, so it does not replace the requested V2 control.

    All runtime tests used isolated configuration/history. No installed binary, gateway configuration, model group, or global feature was changed. An isolated app-server config/read also verified trusted project configuration precedence, but native App UI initiation was not exercised: the available UI tool refused access to com.openai.codex. The successful evidence is explicitly bundled-backend execution, not a claim of complete UI or V2 lifecycle acceptance.

  4. cgasgarth commented on Oct 5, 2026

    @cgasgarth

    Verified a small local plaintext-V2 prototype on October 4, 2026, built from official rust-v0.160.0 source, without adopting a third-party fork.

    The source patch changes two files:

    1. When an explicit local environment flag is enabled, omit the encryption annotation on message for spawn_agent, send_message, and followup_task.
    2. Route these newly generated arguments into the existing AgentMessage::Plaintext path, including Code Mode calls, rather than requiring the server-supplied empty encrypted-argument marker.

    The test configuration uses the ordinary agents namespace, not the reserved collaboration schema. An actual GPT request through VibeProxy accepted this schema and returned readable function arguments (HTTP 200). This is producer-side plaintext selection, not decryption or relabeling sealed bytes.

    Real execution results:

    Test Result
    GPT Sol → Claude Fable, Claude Opus, GPT Luna All three children completed initial shell/file tasks, messages, and follow-up shell/file tasks
    Claude Opus → GPT Luna Initial task, messages, and follow-up completed
    App-server JSON-RPC: GPT Sol → Opus → GPT Luna Grandchild wrote a nonce-bearing computed artifact; both parents verified it and received results

    Children used fork_turns="none". Independent checks validated the generated files. Saved runtime records confirmed the requested model IDs, vibeproxy provider, and V2 for all nine sessions; 34 inter-agent input records contained zero encrypted content parts. All 12 existing multi-agent schema tests passed with the flag disabled.

    Patch, launch wrapper, reproducible real-request probes, and sanitized verification summary:
    https://github.com/cgasgarth/skills/tree/e5b3134/patches/v2-plaintext

    Scope: isolated CLI and app-server backend execution, not a claim that desktop UI initiation has been verified. The installed app was not modified or restarted during these tests. Its CODEX_CLI_PATH override can select the external backend. Existing encrypted history is not decrypted. Images, compaction, resumed encrypted chats, and other providers were not tested. This remains a local prototype, not a supported upstream config setting.

    A supported upstream plaintext delivery policy covering both schema production and message classification would remove the need for this patch. Related: #37197 and #34833.

  5. cgasgarth commented on Oct 5, 2026

    @cgasgarth

    Confirmed a configuration-only solution on October 5, 2026, using the official signed Codex 0.160.0 backend and VibeProxy's bundled CLIProxyAPI 8.0.4. This supersedes my earlier local-build prototype.

    In VibeProxy's persistent config, enable the existing setting:

    codex:
      optimize-multi-agent-v2: true

    In Codex, enable features.multi_agent_v2.enabled = true, use the normal collaboration namespace, and mark the model catalog entries multi_agent_version: "v2". That last step matters: Codex's V2 child-tool visibility check requires the child model's catalog entry to advertise V2. A global V2 feature override alone can spawn the child while leaving its collaboration tools unavailable. Restart the app after changing the catalog.

    Verified through two actual desktop-app chats, created with the native create_thread tool:

    Direction Initial task Explicit send_message Same-child follow-up
    GPT Sol → Claude Opus Executed shell arithmetic; correct result Separate MESSAGE reached the parent Executed arithmetic and delivered another separate MESSAGE
    Claude Opus → GPT Sol Executed shell arithmetic; correct result Separate MESSAGE reached the parent Executed arithmetic and delivered another separate MESSAGE

    These were app chats, not CLI-only or standalone app-server probes. Native thread creation, follow-up messaging, thread reads, and waits remained available. No custom Codex binary, app-bundle patch, signing workaround, or test suite is needed.

    The earlier locally built Codex backend was incompatible with the packaged app's native-tool peer authorization (missing-code-signing-identity), matching #34583. It has been removed. Keeping the official signed backend avoids that regression.

    The existing proxy implementation removes task-encryption annotations and adapts the namespace and inter-agent inputs. It does not decrypt old sealed tasks. Sources:

    This confirms the two directions above on this setup; it is not a claim about all proxies or all providers.

  6. yuzhichang commented on Nov 3, 2026

    @yuzhichang

    Adding one piece of evidence that I think reframes this, plus a second failure point
    that the plaintext-arguments workaround alone does not fix.

    1. The payload is already plaintext; it is just filed under the wrong key

    On a third-party Responses provider, encrypted_content does not contain ciphertext —
    it contains the task text verbatim, because nothing on that path actually encrypts. A
    recorded rollout from rust-v0.166.0 (parent /root, child /root/quantum_core):

    type: agent_message   author: /root   recipient: /root/quantum_core
      input_text        = "Message Type: NEW_TASK\nTask name: /root/quantum_core\n
                           Sender: /root\nPayload:\n"
      encrypted_content = "请用中文总结「量子计算(Quantum Computing)」的三个核心概念。要求:…"
    

    So this is not a decryption problem and does not need a decryption story. The text is
    sitting in the field that every renderer treats as opaque. That is consistent with the
    message_delivery = "plaintext" request: the only thing missing is permission to put it
    in content instead.

    2. Plaintext arguments are necessary but not sufficient

    AgentMessage::Plaintext still ends up as ResponseItem::AgentMessage —
    InterAgentCommunication::to_model_input_item unconditionally builds that item, and
    agent_message is a first-party Responses type. A third-party endpoint drops it, so the
    child sees nothing even when the arguments arrive as plain text. Confirmed on a MiniMax
    /responses endpoint: the parent's spawn_agent call carries readable arguments, the
    child thread starts, and its first user-visible item is empty.

    So there are two independent wire-level assumptions here, not one:

    • the collaboration message parameter is annotated encrypted in the tool schema;
    • the delivered item type is agent_message.

    Both need to be overridable for a non-OpenAI child, and I would argue they should be one
    knob rather than two, since a deployment that needs one needs both.

    3. A suggestion on where the knob lives

    An environment variable works for a single-purpose process, but an app-server serves many
    threads and possibly several providers, so a process-global flag cannot express "this
    child is on MiniMax, that one is on OpenAI". features.multi_agent_v2 already carries
    per-thread settings (wait timeouts, hint text, namespace, model-override visibility), so
    message_delivery = "encrypted" | "plaintext" fits the existing shape:

    [features.multi_agent_v2]
    message_delivery = "plaintext"

    One correctness note for whoever implements it: the delivery decision must be recorded
    on the InterAgentCommunication
    , not re-derived from config when the item is rendered.
    to_model_input_item also runs during rollout replay and memories serialization, where
    the ambient config may be absent or different from the one in force at delivery time;
    re-deriving there silently changes a child's reconstructed history. A default-off boolean
    on the struct (skipped when false, so existing rollouts and the default wire payload are
    unchanged) is enough.

    4. Testing

    Worth covering, in my experience of writing this: absent encrypted_function_args under
    each policy, real ciphertext never downgraded, non-message collaboration tools
    (wait_agent etc.) unaffected, and the schema annotation for all three tools under both
    policies.

    I have a local branch against rust-v0.166.0 implementing the config option plus the
    persisted decision, with tests for the cases above (cargo check -p codex-core -p codex-protocol -p codex-features -p codex-app-server clean; the new tests pass). I am
    not opening a PR since docs/contributing.md says external code contributions are not
    accepted. The full diff is below, purely as a reference for whoever picks this up — not as
    a request to review or merge it.

    Reference diff (against rust-v0.166.0, two commits, 15 files)
    diff --git a/codex-rs/core/src/agent/control/api.rs b/codex-rs/core/src/agent/control/api.rs
    index 0426ca3..a36c20b 100644
    --- a/codex-rs/core/src/agent/control/api.rs
    +++ b/codex-rs/core/src/agent/control/api.rs
    @@ -88,7 +88,12 @@ impl AgentControl for LocalAgentControl {
                                 CodexErr::InvalidRequest("spawn input needs a child path".to_string())
                             })?;
                         SpawnInitialInput::InterAgentCommunication(
    -                        message.into_communication(author, recipient, mode),
    +                        message.into_communication(
    +                            author,
    +                            recipient,
    +                            mode,
    +                            config.multi_agent_v2.message_delivery,
    +                        ),
                             AgentCommunicationContext::new(AgentCommunicationKind::Spawn, caller),
                         )
                     }
    @@ -138,6 +143,9 @@ impl AgentControl for LocalAgentControl {
                                 "target agent is missing an agent_path".to_string(),
                             )
                         })?;
    +                    // Capture the delivery policy before `resume_config` is moved into the
    +                    // optional reload below.
    +                    let message_delivery = resume_config.multi_agent_v2.message_delivery;
                         // Cold-restored children still reload lazily on any message. Only
                         // locally evicted recipients can retain mail without reloading.
                         // Loaded recipients go straight to delivery, which rejects sends
    @@ -151,7 +159,8 @@ impl AgentControl for LocalAgentControl {
                         } else {
                             None
                         };
    -                    let communication = message.into_communication(author, receiver_path, mode);
    +                    let communication =
    +                        message.into_communication(author, receiver_path, mode, message_delivery);
                         let kind = match mode {
                             MessageDeliveryMode::QueueOnly => {
                                 start_options.parent_turn_id = None;
    diff --git a/codex-rs/core/src/agent/control/delivery.rs b/codex-rs/core/src/agent/control/delivery.rs
    index 0cc53ae..e52981b 100644
    --- a/codex-rs/core/src/agent/control/delivery.rs
    +++ b/codex-rs/core/src/agent/control/delivery.rs
    @@ -5,6 +5,7 @@ use crate::agent::types::MessageDeliveryMode;
     use crate::context::ContextualUserFragment;
     use crate::context::InterAgentMessage;
     use crate::context::InterAgentMessageType;
    +use codex_features::MultiAgentMessageDelivery;
     use codex_protocol::AgentPath;
     use codex_protocol::protocol::InterAgentCommunication;
     
    @@ -14,6 +15,7 @@ impl AgentMessage {
             author: AgentPath,
             recipient: AgentPath,
             mode: MessageDeliveryMode,
    +        message_delivery: MultiAgentMessageDelivery,
         ) -> InterAgentCommunication {
             let trigger_turn = mode == MessageDeliveryMode::TriggerTurn;
             match self {
    @@ -38,7 +40,22 @@ impl AgentMessage {
                     .render()
                     .into_text()
                     .unwrap_or_default();
    -                InterAgentCommunication::new(author, recipient, Vec::new(), content, trigger_turn)
    +                // The delivery policy is stamped onto the communication so the child's history
    +                // (and any replay of it) renders the same item type it originally received.
    +                match message_delivery {
    +                    MultiAgentMessageDelivery::Plaintext => {
    +                        InterAgentCommunication::new_portable_plaintext(
    +                            author,
    +                            recipient,
    +                            Vec::new(),
    +                            content,
    +                            trigger_turn,
    +                        )
    +                    }
    +                    MultiAgentMessageDelivery::Encrypted => {
    +                        InterAgentCommunication::new(author, recipient, Vec::new(), content, trigger_turn)
    +                    }
    +                }
                 }
             }
         }
    diff --git a/codex-rs/core/src/config/mod.rs b/codex-rs/core/src/config/mod.rs
    index eb949b8..479d96d 100644
    --- a/codex-rs/core/src/config/mod.rs
    +++ b/codex-rs/core/src/config/mod.rs
    @@ -74,6 +74,7 @@ use codex_features::FeatureOverrides;
     use codex_features::FeatureToml;
     use codex_features::Features;
     use codex_features::FeaturesToml;
    +use codex_features::MultiAgentMessageDelivery;
     use codex_features::MultiAgentV2ConfigToml;
     use codex_features::NetworkProxyConfigToml;
     use codex_features::SleepToolMode;
    @@ -1407,6 +1408,10 @@ pub struct MultiAgentV2Config {
         pub message_board_in_memory: bool,
         pub message_board_remote: Option<codex_features::RemoteMessageBoardConfigToml>,
         pub non_code_mode_only: bool,
    +    /// How collaboration task messages reach the child's model. `Encrypted` is upstream's
    +    /// behavior; `Plaintext` hands the task over as an ordinary user message so a provider
    +    /// that does not render `agent_message` still sees the assignment.
    +    pub message_delivery: MultiAgentMessageDelivery,
     }
     
     impl MultiAgentV2Config {
    @@ -1431,6 +1436,7 @@ impl MultiAgentV2Config {
                 message_board_in_memory: false,
                 message_board_remote: None,
                 non_code_mode_only: true,
    +            message_delivery: MultiAgentMessageDelivery::default(),
             }
         }
     }
    @@ -2936,6 +2942,9 @@ fn resolve_multi_agent_v2_config(config_toml: &ConfigToml) -> MultiAgentV2Config
         let non_code_mode_only = base
             .and_then(|config| config.non_code_mode_only)
             .unwrap_or(default.non_code_mode_only);
    +    let message_delivery = base
    +        .and_then(|config| config.message_delivery)
    +        .unwrap_or(default.message_delivery);
     
         MultiAgentV2Config {
             max_concurrent_threads_per_session,
    @@ -2957,6 +2966,7 @@ fn resolve_multi_agent_v2_config(config_toml: &ConfigToml) -> MultiAgentV2Config
             message_board_in_memory,
             message_board_remote: base.and_then(|config| config.message_board_remote.clone()),
             non_code_mode_only,
    +        message_delivery,
         }
     }
     
    diff --git a/codex-rs/core/src/tools/handlers/multi_agents_spec.rs b/codex-rs/core/src/tools/handlers/multi_agents_spec.rs
    index edc9467..95a0c3b 100644
    --- a/codex-rs/core/src/tools/handlers/multi_agents_spec.rs
    +++ b/codex-rs/core/src/tools/handlers/multi_agents_spec.rs
    @@ -1,5 +1,6 @@
     use crate::agent::child_config::MAX_SPAWN_AGENT_MODEL_OVERRIDES;
     use crate::agent::child_config::model_supports_multi_agent_backend;
    +use codex_features::MultiAgentMessageDelivery;
     use codex_protocol::openai_models::ModelPreset;
     use codex_protocol::protocol::MultiAgentVersion;
     use codex_tools::JsonSchema;
    @@ -23,6 +24,27 @@ const SPAWN_AGENT_MODEL_OVERRIDE_DESCRIPTION: &str =
         "Model override for the new agent. Omit unless an explicit override is needed.";
     const MAX_REASONING_EFFORT_CHARS_IN_SPAWN_AGENT_DESCRIPTION: usize = 64;
     
    +/// Applies upstream's `encrypted` annotation to a collaboration `message` field unless the
    +/// deployment opted into plaintext delivery.
    +///
    +/// The annotation tells the backend to treat the argument as ciphertext. A third-party
    +/// Responses provider cannot produce or consume that form, so it either returns an opaque
    +/// payload or the child receives `encrypted_content` it cannot read
    +/// (openai/codex#34833, #36376, #46939). With `message_delivery = "plaintext"` the annotation
    +/// is dropped and the provider returns the plain text it already has.
    +///
    +/// The decision lives in config rather than an environment variable so two threads, or two
    +/// providers, in one process can differ.
    +fn collaboration_message_schema(
    +    schema: JsonSchema,
    +    message_delivery: MultiAgentMessageDelivery,
    +) -> JsonSchema {
    +    match message_delivery {
    +        MultiAgentMessageDelivery::Encrypted => schema.with_encrypted(),
    +        MultiAgentMessageDelivery::Plaintext => schema,
    +    }
    +}
    +
     #[derive(Debug, Clone)]
     pub struct SpawnAgentToolOptions {
         pub available_models: Vec<ModelPreset>,
    @@ -33,6 +55,9 @@ pub struct SpawnAgentToolOptions {
         pub multi_agent_version: MultiAgentVersion,
         pub model_catalog_in_context: bool,
         pub usage_hint_text: Option<String>,
    +    /// Shape of the collaboration `message` parameter schema, mirroring the thread's
    +    /// `multi_agent_v2.message_delivery`.
    +    pub message_delivery: MultiAgentMessageDelivery,
     }
     
     impl Default for SpawnAgentToolOptions {
    @@ -46,6 +71,7 @@ impl Default for SpawnAgentToolOptions {
                 multi_agent_version: MultiAgentVersion::Disabled,
                 model_catalog_in_context: false,
                 usage_hint_text: None,
    +            message_delivery: MultiAgentMessageDelivery::default(),
             }
         }
     }
    @@ -122,7 +148,10 @@ pub fn create_spawn_agent_tool_v2(
             (options.expose_spawn_agent_model_overrides && !options.hide_agent_type_model_reasoning)
                 .then_some(SPAWN_AGENT_INHERITED_MODEL_GUIDANCE)
         };
    -    let mut properties = spawn_agent_common_properties_v2(&options.agent_type_description);
    +    let mut properties = spawn_agent_common_properties_v2(
    +        &options.agent_type_description,
    +        options.message_delivery,
    +    );
         if !options.expose_agent_type {
             properties.remove("agent_type");
         }
    @@ -201,7 +230,7 @@ pub fn create_send_input_tool_v1() -> ToolSpec {
         })
     }
     
    -pub fn create_send_message_tool() -> ToolSpec {
    +pub fn create_send_message_tool(message_delivery: MultiAgentMessageDelivery) -> ToolSpec {
         let properties = BTreeMap::from([
             (
                 "target".to_string(),
    @@ -211,10 +240,12 @@ pub fn create_send_message_tool() -> ToolSpec {
             ),
             (
                 "message".to_string(),
    -            JsonSchema::string(Some(
    -                "Message text to queue on the target agent.".to_string(),
    -            ))
    -            .with_encrypted(),
    +            collaboration_message_schema(
    +                JsonSchema::string(Some(
    +                    "Message text to queue on the target agent.".to_string(),
    +                )),
    +                message_delivery,
    +            ),
             ),
         ]);
     
    @@ -233,7 +264,7 @@ pub fn create_send_message_tool() -> ToolSpec {
         })
     }
     
    -pub fn create_followup_task_tool() -> ToolSpec {
    +pub fn create_followup_task_tool(message_delivery: MultiAgentMessageDelivery) -> ToolSpec {
         let properties = BTreeMap::from([
             (
                 "target".to_string(),
    @@ -244,10 +275,12 @@ pub fn create_followup_task_tool() -> ToolSpec {
             ),
             (
                 "message".to_string(),
    -            JsonSchema::string(Some(
    -                "Message text to send to the target agent.".to_string(),
    -            ))
    -            .with_encrypted(),
    +            collaboration_message_schema(
    +                JsonSchema::string(Some(
    +                    "Message text to send to the target agent.".to_string(),
    +                )),
    +                message_delivery,
    +            ),
             ),
         ]);
     
    @@ -646,14 +679,19 @@ fn spawn_agent_common_properties_v1(agent_type_description: &str) -> BTreeMap<St
         ])
     }
     
    -fn spawn_agent_common_properties_v2(agent_type_description: &str) -> BTreeMap<String, JsonSchema> {
    +fn spawn_agent_common_properties_v2(
    +    agent_type_description: &str,
    +    message_delivery: MultiAgentMessageDelivery,
    +) -> BTreeMap<String, JsonSchema> {
         BTreeMap::from([
             (
                 "message".to_string(),
    -            JsonSchema::string(Some(
    -                "Initial plain-text task for the new agent.".to_string(),
    -            ))
    -            .with_encrypted(),
    +            collaboration_message_schema(
    +                JsonSchema::string(Some(
    +                    "Initial plain-text task for the new agent.".to_string(),
    +                )),
    +                message_delivery,
    +            ),
             ),
             (
                 "agent_type".to_string(),
    diff --git a/codex-rs/core/src/tools/handlers/multi_agents_spec_tests.rs b/codex-rs/core/src/tools/handlers/multi_agents_spec_tests.rs
    index d74729e..39dee3d 100644
    --- a/codex-rs/core/src/tools/handlers/multi_agents_spec_tests.rs
    +++ b/codex-rs/core/src/tools/handlers/multi_agents_spec_tests.rs
    @@ -245,7 +245,7 @@ fn send_message_tool_requires_message_and_has_no_output_schema() {
             parameters,
             output_schema,
             ..
    -    }) = create_send_message_tool()
    +    }) = create_send_message_tool(Default::default())
         else {
             panic!("send_message should be a function tool");
         };
    @@ -288,7 +288,7 @@ fn followup_task_tool_requires_message_and_has_no_output_schema() {
             parameters,
             output_schema,
             ..
    -    }) = create_followup_task_tool()
    +    }) = create_followup_task_tool(Default::default())
         else {
             panic!("followup_task should be a function tool");
         };
    @@ -415,3 +415,56 @@ fn list_agents_tool_status_schema_includes_interrupted() {
             ])
         );
     }
    +
    +/// A third-party Responses provider cannot produce the encrypted argument form, so the
    +/// plaintext policy must drop the annotation on every collaboration message parameter.
    +/// Otherwise the provider either returns opaque text or the child receives an unreadable
    +/// `encrypted_content` (openai/codex#34833, #36376, #46939).
    +#[test]
    +fn plaintext_delivery_drops_the_encrypted_annotation() {
    +    let encrypted_annotation = |tool: ToolSpec| -> Option<bool> {
    +        let ToolSpec::Function(ResponsesApiTool { parameters, .. }) = tool else {
    +            panic!("collaboration tools should be function tools");
    +        };
    +        parameters
    +            .properties
    +            .expect("object params")
    +            .get("message")
    +            .and_then(|schema| schema.encrypted)
    +    };
    +
    +    for delivery in [
    +        MultiAgentMessageDelivery::Encrypted,
    +        MultiAgentMessageDelivery::Plaintext,
    +    ] {
    +        let spawn = create_spawn_agent_tool_v2(
    +            SpawnAgentToolOptions {
    +                agent_type_description: "role help".to_string(),
    +                expose_agent_type: true,
    +                expose_spawn_agent_model_overrides: false,
    +                message_delivery: delivery,
    +                ..SpawnAgentToolOptions::default()
    +            },
    +            /*description_override*/ None,
    +        );
    +        let expected = match delivery {
    +            MultiAgentMessageDelivery::Encrypted => Some(true),
    +            MultiAgentMessageDelivery::Plaintext => None,
    +        };
    +        assert_eq!(
    +            encrypted_annotation(spawn),
    +            expected,
    +            "spawn_agent under {delivery:?}"
    +        );
    +        assert_eq!(
    +            encrypted_annotation(create_send_message_tool(delivery)),
    +            expected,
    +            "send_message under {delivery:?}"
    +        );
    +        assert_eq!(
    +            encrypted_annotation(create_followup_task_tool(delivery)),
    +            expected,
    +            "followup_task under {delivery:?}"
    +        );
    +    }
    +}
    diff --git a/codex-rs/core/src/tools/handlers/multi_agents_tests.rs b/codex-rs/core/src/tools/handlers/multi_agents_tests.rs
    index d5a8dcc..7f48dd4 100644
    --- a/codex-rs/core/src/tools/handlers/multi_agents_tests.rs
    +++ b/codex-rs/core/src/tools/handlers/multi_agents_tests.rs
    @@ -1193,7 +1193,7 @@ async fn multi_agent_v2_spawn_returns_path_and_send_message_accepts_relative_pat
             json!(r#"<agent name="/root/test_process" />"#),
         );
     
    -    SendMessageHandlerV2
    +    SendMessageHandlerV2::new(Default::default())
             .handle(invocation(
                 session.clone(),
                 turn.clone(),
    @@ -1350,7 +1350,7 @@ async fn multi_agent_v2_send_message_accepts_root_target_from_child() {
             agent_role: None,
         });
     
    -    SendMessageHandlerV2
    +    SendMessageHandlerV2::new(Default::default())
             .handle(invocation(
                 Arc::new(session),
                 Arc::new(turn),
    @@ -1427,7 +1427,7 @@ async fn multi_agent_v2_followup_task_rejects_root_target_from_child() {
             agent_role: None,
         });
     
    -    let Err(err) = FollowupTaskHandlerV2
    +    let Err(err) = FollowupTaskHandlerV2::new(Default::default())
             .handle(invocation(
                 Arc::new(session),
                 Arc::new(turn),
    @@ -1813,7 +1813,7 @@ async fn multi_agent_v2_send_message_rejects_legacy_items_field() {
             })),
         );
     
    -    let Err(err) = SendMessageHandlerV2.handle(invocation).await else {
    +    let Err(err) = SendMessageHandlerV2::new(Default::default()).handle(invocation).await else {
             panic!("legacy items field should be rejected in v2");
         };
         let FunctionCallError::RespondToModel(message) = err else {
    @@ -1868,7 +1868,7 @@ async fn multi_agent_v2_send_message_rejects_interrupt_parameter() {
             })),
         );
     
    -    let Err(err) = SendMessageHandlerV2.handle(invocation).await else {
    +    let Err(err) = SendMessageHandlerV2::new(Default::default()).handle(invocation).await else {
             panic!("send_message interrupt parameter should be rejected");
         };
         let FunctionCallError::RespondToModel(message) = err else {
    @@ -1957,7 +1957,7 @@ async fn multi_agent_v2_followup_task_completion_notifies_parent_on_every_turn()
             )
             .await;
     
    -    FollowupTaskHandlerV2
    +    FollowupTaskHandlerV2::new(Default::default())
             .handle(invocation(
                 session,
                 turn,
    @@ -2098,7 +2098,7 @@ async fn multi_agent_v2_followup_task_rejects_legacy_items_field() {
             })),
         );
     
    -    let Err(err) = FollowupTaskHandlerV2.handle(invocation).await else {
    +    let Err(err) = FollowupTaskHandlerV2::new(Default::default()).handle(invocation).await else {
             panic!("legacy items field should be rejected in v2");
         };
         let FunctionCallError::RespondToModel(message) = err else {
    diff --git a/codex-rs/core/src/tools/handlers/multi_agents_v2/followup_task.rs b/codex-rs/core/src/tools/handlers/multi_agents_v2/followup_task.rs
    index fa12970..4c1b1bf 100644
    --- a/codex-rs/core/src/tools/handlers/multi_agents_v2/followup_task.rs
    +++ b/codex-rs/core/src/tools/handlers/multi_agents_v2/followup_task.rs
    @@ -6,7 +6,15 @@ use crate::agent::types::MessageDeliveryMode;
     use crate::tools::handlers::multi_agents_spec::create_followup_task_tool;
     use codex_tools::ToolSpec;
     
    -pub(crate) struct Handler;
    +pub(crate) struct Handler {
    +    message_delivery: codex_features::MultiAgentMessageDelivery,
    +}
    +
    +impl Handler {
    +    pub(crate) fn new(message_delivery: codex_features::MultiAgentMessageDelivery) -> Self {
    +        Self { message_delivery }
    +    }
    +}
     
     impl ToolExecutor<ToolInvocation> for Handler {
         fn tool_name(&self) -> ToolName {
    @@ -14,7 +22,7 @@ impl ToolExecutor<ToolInvocation> for Handler {
         }
     
         fn spec(&self) -> ToolSpec {
    -        create_followup_task_tool()
    +        create_followup_task_tool(self.message_delivery)
         }
     
         fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
    diff --git a/codex-rs/core/src/tools/handlers/multi_agents_v2/send_message.rs b/codex-rs/core/src/tools/handlers/multi_agents_v2/send_message.rs
    index 7713f01..39938cd 100644
    --- a/codex-rs/core/src/tools/handlers/multi_agents_v2/send_message.rs
    +++ b/codex-rs/core/src/tools/handlers/multi_agents_v2/send_message.rs
    @@ -6,7 +6,15 @@ use crate::agent::types::MessageDeliveryMode;
     use crate::tools::handlers::multi_agents_spec::create_send_message_tool;
     use codex_tools::ToolSpec;
     
    -pub(crate) struct Handler;
    +pub(crate) struct Handler {
    +    message_delivery: codex_features::MultiAgentMessageDelivery,
    +}
    +
    +impl Handler {
    +    pub(crate) fn new(message_delivery: codex_features::MultiAgentMessageDelivery) -> Self {
    +        Self { message_delivery }
    +    }
    +}
     
     impl ToolExecutor<ToolInvocation> for Handler {
         fn tool_name(&self) -> ToolName {
    @@ -14,7 +22,7 @@ impl ToolExecutor<ToolInvocation> for Handler {
         }
     
         fn spec(&self) -> ToolSpec {
    -        create_send_message_tool()
    +        create_send_message_tool(self.message_delivery)
         }
     
         fn handle<'a>(&'a self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'a>
    diff --git a/codex-rs/core/src/tools/parallel.rs b/codex-rs/core/src/tools/parallel.rs
    index ffb17eb..0392e21 100644
    --- a/codex-rs/core/src/tools/parallel.rs
    +++ b/codex-rs/core/src/tools/parallel.rs
    @@ -110,7 +110,13 @@ impl ToolCallRuntime {
             cancellation_token: CancellationToken,
         ) -> impl std::future::Future<Output = Result<ResponseItemEnvelope, CodexErr>> {
             let error_call = call.clone();
    -        let source = call.direct_source();
    +        let source = call.direct_source(
    +            self.step_context
    +                .turn
    +                .config
    +                .multi_agent_v2
    +                .message_delivery,
    +        );
             let recorder = self.session.services.executed_tool_calls.clone();
             let recorded_call = recorder.prepare_direct_call(&call, &source, &self.step_context);
             let step_context = Arc::clone(&self.step_context);
    diff --git a/codex-rs/core/src/tools/router.rs b/codex-rs/core/src/tools/router.rs
    index 36fbfe4..546b6c7 100644
    --- a/codex-rs/core/src/tools/router.rs
    +++ b/codex-rs/core/src/tools/router.rs
    @@ -17,6 +17,7 @@ use crate::tools::registry::ToolExposure;
     use crate::tools::registry::ToolRegistry;
     #[cfg(test)]
     use crate::tools::spec_plan::finalize_tool_router;
    +use codex_features::MultiAgentMessageDelivery;
     use codex_otel::SessionTelemetry;
     use codex_otel::TOOL_REGISTRATIONS_METRIC;
     use codex_otel::TOOL_REGISTRATIONS_METRIC_BUCKETS;
    @@ -53,17 +54,28 @@ pub struct ToolCall {
     }
     
     impl ToolCall {
    -    pub(crate) fn direct_source(&self) -> ToolCallSource {
    -        if self.tool_name.namespace.as_deref() == Some("collaboration")
    +    /// Classifies a collaboration call as plaintext or encrypted delivery.
    +    ///
    +    /// Upstream selects the plaintext path only for an explicit empty
    +    /// `encrypted_function_args` marker, which is a backend-supplied signal. A third-party
    +    /// Responses provider never emits the field at all, so a deployment that configures
    +    /// `features.multi_agent_v2.message_delivery = "plaintext"` treats the ABSENT marker as
    +    /// plaintext for the three collaboration message tools. Real ciphertext
    +    /// (`Some(non-empty)`) is never downgraded, and the upstream `Some([])` marker keeps
    +    /// working unchanged.
    +    pub(crate) fn direct_source(&self, message_delivery: MultiAgentMessageDelivery) -> ToolCallSource {
    +        let is_collaboration_message = 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)
    -        {
    +            );
    +        let backend_plaintext_marker = self
    +            .encrypted_function_args
    +            .as_ref()
    +            .is_some_and(Vec::is_empty);
    +        let configured_plaintext = message_delivery == MultiAgentMessageDelivery::Plaintext
    +            && self.encrypted_function_args.is_none();
    +        if is_collaboration_message && (backend_plaintext_marker || configured_plaintext) {
                 ToolCallSource::DirectPlaintextMessage
             } else {
                 ToolCallSource::Direct
    diff --git a/codex-rs/core/src/tools/router_tests.rs b/codex-rs/core/src/tools/router_tests.rs
    index 498fe97..1b50c07 100644
    --- a/codex-rs/core/src/tools/router_tests.rs
    +++ b/codex-rs/core/src/tools/router_tests.rs
    @@ -25,6 +25,7 @@ use codex_protocol::dynamic_tools::DynamicToolNamespaceSpec;
     use codex_protocol::dynamic_tools::DynamicToolNamespaceTool;
     use codex_protocol::dynamic_tools::DynamicToolSpec;
     use codex_protocol::models::ContentItem;
    +use codex_features::MultiAgentMessageDelivery;
     use codex_protocol::models::FunctionCallOutputBody;
     use codex_protocol::models::ResponseItem;
     use codex_tools::ResponsesApiNamespace;
    @@ -59,6 +60,75 @@ fn tool_log_payload_redacts_plaintext_multi_agent_messages() {
         );
     }
     
    +fn collaboration_call(
    +    tool: &str,
    +    encrypted_function_args: Option<Vec<String>>,
    +) -> ToolCall {
    +    ToolCall {
    +        tool_name: ToolName::namespaced("collaboration", tool),
    +        call_id: "call-1".to_string(),
    +        payload: ToolPayload::Function {
    +            arguments: json!({}).to_string(),
    +        },
    +        encrypted_function_args,
    +    }
    +}
    +
    +/// A third-party Responses provider never emits `encrypted_function_args`, so the upstream
    +/// `Some([])` marker is absent and plaintext delivery would be unreachable. Configuring
    +/// `message_delivery = "plaintext"` makes the absent marker select the plaintext path
    +/// (openai/codex#34833, #36376, #46939).
    +#[test]
    +fn plaintext_policy_routes_absent_marker_to_plaintext() {
    +    for tool in ["spawn_agent", "send_message", "followup_task"] {
    +        assert_eq!(
    +            collaboration_call(tool, /*encrypted_function_args*/ None)
    +                .direct_source(MultiAgentMessageDelivery::Plaintext),
    +            ToolCallSource::DirectPlaintextMessage,
    +            "{tool} should be plaintext under the plaintext policy"
    +        );
    +    }
    +}
    +
    +/// The plaintext policy must not change behavior for anyone who leaves the default in place.
    +#[test]
    +fn encrypted_policy_keeps_absent_marker_encrypted() {
    +    for tool in ["spawn_agent", "send_message", "followup_task"] {
    +        assert_eq!(
    +            collaboration_call(tool, /*encrypted_function_args*/ None)
    +                .direct_source(MultiAgentMessageDelivery::Encrypted),
    +            ToolCallSource::Direct,
    +            "{tool} must stay encrypted by default"
    +        );
    +    }
    +}
    +
    +/// Real ciphertext is never downgraded, whatever the policy says.
    +#[test]
    +fn ciphertext_is_never_downgraded_by_plaintext_policy() {
    +    for tool in ["spawn_agent", "send_message", "followup_task"] {
    +        assert_eq!(
    +            collaboration_call(tool, Some(vec!["gAAAA-ciphertext".to_string()]))
    +                .direct_source(MultiAgentMessageDelivery::Plaintext),
    +            ToolCallSource::Direct,
    +            "{tool} carries ciphertext and must stay encrypted"
    +        );
    +    }
    +}
    +
    +/// The policy only covers collaboration message tools; other tools keep their source.
    +#[test]
    +fn plaintext_policy_does_not_affect_other_collaboration_tools() {
    +    for tool in ["wait_agent", "list_agents", "interrupt_agent"] {
    +        assert_eq!(
    +            collaboration_call(tool, /*encrypted_function_args*/ None)
    +                .direct_source(MultiAgentMessageDelivery::Plaintext),
    +            ToolCallSource::Direct,
    +            "{tool} carries no task payload"
    +        );
    +    }
    +}
    +
     impl codex_extension_api::ToolContributor for ExtensionEchoContributor {
         fn tools(
             &self,
    @@ -230,7 +300,10 @@ async fn build_tool_call_uses_namespace_for_registry_name() -> anyhow::Result<()
         );
         assert_eq!(call.call_id, "call-namespace");
         assert_eq!(call.encrypted_function_args, Some(Vec::new()));
    -    assert_eq!(call.direct_source(), ToolCallSource::Direct);
    +    assert_eq!(
    +        call.direct_source(Default::default()),
    +        ToolCallSource::Direct
    +    );
         match call.payload {
             ToolPayload::Function { arguments } => {
                 assert_eq!(arguments, "{}");
    diff --git a/codex-rs/core/src/tools/spec_plan.rs b/codex-rs/core/src/tools/spec_plan.rs
    index 2602fcb..1563803 100644
    --- a/codex-rs/core/src/tools/spec_plan.rs
    +++ b/codex-rs/core/src/tools/spec_plan.rs
    @@ -1466,6 +1466,7 @@ fn add_collaboration_tools(context: &CoreToolPlanContext<'_>, registry: &mut Too
                     ToolExposure::Direct
                 };
                 let tool_namespace = turn_context.config.multi_agent_v2.tool_namespace.as_deref();
    +            let message_delivery = turn_context.config.multi_agent_v2.message_delivery;
                 let agent_type_description =
                     agent_type_description(turn_context, context.default_agent_type_description);
                 let hide_spawn_agent_metadata =
    @@ -1492,6 +1493,7 @@ fn add_collaboration_tools(context: &CoreToolPlanContext<'_>, registry: &mut Too
                                     .multi_agent_v2
                                     .usage_hint_text
                                     .clone(),
    +                            message_delivery,
                             },
                             spawn_agent_description.map(str::to_owned),
                         ),
    @@ -1506,7 +1508,7 @@ fn add_collaboration_tools(context: &CoreToolPlanContext<'_>, registry: &mut Too
                 if !turn_context.config.multi_agent_v2.disable_direct_message {
                     registry.register_trusted_with_exposure(
                         multi_agent_v2_handler(
    -                        SendMessageHandlerV2,
    +                        SendMessageHandlerV2::new(message_delivery),
                             tool_namespace,
                             model_messages.multi_agent_tool_description_override("send_message"),
                             model_messages.multi_agent_tool_parameters_override("send_message"),
    @@ -1515,7 +1517,7 @@ fn add_collaboration_tools(context: &CoreToolPlanContext<'_>, registry: &mut Too
                     );
                     registry.register_trusted_with_exposure(
                         multi_agent_v2_handler(
    -                        FollowupTaskHandlerV2,
    +                        FollowupTaskHandlerV2::new(message_delivery),
                             tool_namespace,
                             model_messages.multi_agent_tool_description_override("followup_task"),
                             model_messages.multi_agent_tool_parameters_override("followup_task"),
    @@ -1573,6 +1575,7 @@ fn add_collaboration_tools(context: &CoreToolPlanContext<'_>, registry: &mut Too
                         hide_agent_type_model_reasoning: false,
                         expose_spawn_agent_model_overrides: true,
                         usage_hint_text: turn_context.config.multi_agent_v2.usage_hint_text.clone(),
    +                    message_delivery: turn_context.config.multi_agent_v2.message_delivery,
                     }),
                     exposure,
                 );
    diff --git a/codex-rs/features/src/feature_configs.rs b/codex-rs/features/src/feature_configs.rs
    index 1995ea9..f207d9d 100644
    --- a/codex-rs/features/src/feature_configs.rs
    +++ b/codex-rs/features/src/feature_configs.rs
    @@ -298,6 +298,23 @@ impl FeatureConfig for GuardianV3ConfigToml {
         }
     }
     
    +/// How a multi-agent V2 collaboration task reaches the child's model.
    +///
    +/// Codex delivers the task as an `agent_message` response item, a first-party OpenAI Responses
    +/// type. Only OpenAI's backend renders it; a third-party Responses endpoint ignores the item, so
    +/// the child never sees its assignment (openai/codex#34833, #36376, #46939).
    +#[derive(Serialize, Deserialize, Debug, Clone, Copy, Default, PartialEq, Eq, JsonSchema)]
    +#[serde(rename_all = "snake_case")]
    +pub enum MultiAgentMessageDelivery {
    +    /// Send the payload as encrypted content, unchanged upstream behavior.
    +    #[default]
    +    Encrypted,
    +    /// Send the task as an ordinary plaintext `message`/`user` item, the shape every
    +    /// Responses-compatible provider understands. Delivery is already plaintext on a
    +    /// non-OpenAI backend, so nothing is decrypted and nothing is lost from the rollout.
    +    Plaintext,
    +}
    +
     #[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq, JsonSchema)]
     #[serde(deny_unknown_fields)]
     pub struct MultiAgentV2ConfigToml {
    @@ -359,6 +376,12 @@ pub struct MultiAgentV2ConfigToml {
         pub message_board_remote: Option<RemoteMessageBoardConfigToml>,
         #[serde(skip_serializing_if = "Option::is_none")]
         pub non_code_mode_only: Option<bool>,
    +    /// How collaboration task messages reach the child's model. Defaults to `encrypted`.
    +    ///
    +    /// Set to `plaintext` when the child runs on a provider that does not render Codex's
    +    /// first-party `agent_message` item. See [`MultiAgentMessageDelivery`].
    +    #[serde(skip_serializing_if = "Option::is_none")]
    +    pub message_delivery: Option<MultiAgentMessageDelivery>,
     }
     
     impl FeatureConfig for MultiAgentV2ConfigToml {
    diff --git a/codex-rs/features/src/lib.rs b/codex-rs/features/src/lib.rs
    index 129b096..6da2037 100644
    --- a/codex-rs/features/src/lib.rs
    +++ b/codex-rs/features/src/lib.rs
    @@ -29,6 +29,7 @@ pub use feature_configs::GuardianV2ReviewScopeConfigToml;
     pub use feature_configs::GuardianV2TranscriptConfigToml;
     pub use feature_configs::GuardianV2TranscriptSource;
     pub use feature_configs::GuardianV3ConfigToml;
    +pub use feature_configs::MultiAgentMessageDelivery;
     pub use feature_configs::MultiAgentV2ConfigToml;
     pub use feature_configs::NetworkProxyConfigToml;
     pub use feature_configs::NetworkProxyDomainPermissionToml;
    diff --git a/codex-rs/protocol/src/protocol.rs b/codex-rs/protocol/src/protocol.rs
    index 8c419c5..edfdc33 100644
    --- a/codex-rs/protocol/src/protocol.rs
    +++ b/codex-rs/protocol/src/protocol.rs
    @@ -973,6 +973,19 @@ pub struct InterAgentCommunication {
         #[ts(optional)]
         pub internal_chat_message_metadata_passthrough: Option<InternalChatMessageMetadataPassthrough>,
         pub trigger_turn: bool,
    +    /// Render this task as an ordinary `message`/`user` item instead of Codex's first-party
    +    /// `agent_message`.
    +    ///
    +    /// Recorded on the communication itself (not read from ambient config at render time) so a
    +    /// rollout replayed later reproduces exactly the history the child actually saw. Only a
    +    /// plaintext payload can be rendered this way; `encrypted_content` always stays on the
    +    /// `agent_message` path.
    +    #[serde(default, skip_serializing_if = "is_false")]
    +    pub portable_plaintext: bool,
    +}
    +
    +const fn is_false(value: &bool) -> bool {
    +    !*value
     }
     
     impl InterAgentCommunication {
    @@ -992,6 +1005,21 @@ impl InterAgentCommunication {
                 encrypted_content: None,
                 internal_chat_message_metadata_passthrough: None,
                 trigger_turn,
    +            portable_plaintext: false,
    +        }
    +    }
    +
    +    /// Same as [`Self::new`] but renders the task as a portable plaintext user message.
    +    pub fn new_portable_plaintext(
    +        author: AgentPath,
    +        recipient: AgentPath,
    +        other_recipients: Vec<AgentPath>,
    +        content: String,
    +        trigger_turn: bool,
    +    ) -> Self {
    +        Self {
    +            portable_plaintext: true,
    +            ..Self::new(author, recipient, other_recipients, content, trigger_turn)
             }
         }
     
    @@ -1011,6 +1039,7 @@ impl InterAgentCommunication {
                 encrypted_content: Some(encrypted_content),
                 internal_chat_message_metadata_passthrough: None,
                 trigger_turn,
    +            portable_plaintext: false,
             }
         }
     
    @@ -1037,6 +1066,26 @@ impl InterAgentCommunication {
         }
     
         pub fn to_model_input_item(&self) -> ResponseItem {
    +        // A provider that does not render Codex's first-party `agent_message` item still
    +        // understands an ordinary user message, so an opted-in plaintext task is handed over in
    +        // that shape. Ciphertext always keeps the `agent_message` path: there is nothing
    +        // portable to render, and the marker is recorded on the communication rather than read
    +        // from ambient config so a replayed rollout matches what the child actually saw.
    +        if self.portable_plaintext && self.encrypted_content.is_none() {
    +            return ResponseItem::Message {
    +                encrypted_content: None,
    +                status: None,
    +                id: self.id.clone(),
    +                role: "user".to_string(),
    +                content: vec![ContentItem::InputText {
    +                    text: self.content.clone(),
    +                }],
    +                phase: None,
    +                internal_chat_message_metadata_passthrough: self
    +                    .internal_chat_message_metadata_passthrough
    +                    .clone(),
    +            };
    +        }
             let content = match &self.encrypted_content {
                 Some(encrypted_content) => {
                     let message_type = if self.trigger_turn {
    @@ -4936,6 +4985,85 @@ mod tests {
             );
         }
     
    +    /// A provider that does not render Codex's first-party `agent_message` item still
    +    /// understands an ordinary `message`/`user` item, so an opted-in plaintext task must be
    +    /// delivered in that shape (openai/codex#34833, #36376, #46939).
    +    #[test]
    +    fn portable_plaintext_communication_renders_as_user_message() {
    +        let communication = InterAgentCommunication::new_portable_plaintext(
    +            AgentPath::root(),
    +            AgentPath::root().join("worker").expect("recipient path"),
    +            Vec::new(),
    +            "Message Type: NEW_TASK\nPayload:\nsummarize the diff".to_string(),
    +            /*trigger_turn*/ true,
    +        );
    +
    +        assert_eq!(
    +            communication.to_model_input_item(),
    +            ResponseItem::Message {
    +                encrypted_content: None,
    +                status: None,
    +                id: None,
    +                role: "user".to_string(),
    +                content: vec![ContentItem::InputText {
    +                    text: "Message Type: NEW_TASK\nPayload:\nsummarize the diff".to_string(),
    +                }],
    +                phase: None,
    +                internal_chat_message_metadata_passthrough: None,
    +            }
    +        );
    +    }
    +
    +    /// Ciphertext has nothing portable to render, so the flag must not downgrade it: the child
    +    /// would otherwise see an empty task.
    +    #[test]
    +    fn portable_plaintext_flag_never_unwraps_ciphertext() {
    +        let mut communication = InterAgentCommunication::new_encrypted(
    +            AgentPath::root(),
    +            AgentPath::root().join("worker").expect("recipient path"),
    +            Vec::new(),
    +            "gAAAA-ciphertext".to_string(),
    +            /*trigger_turn*/ true,
    +        );
    +        communication.portable_plaintext = true;
    +
    +        assert!(matches!(
    +            communication.to_model_input_item(),
    +            ResponseItem::AgentMessage { .. }
    +        ));
    +    }
    +
    +    /// The marker is persisted with the communication so a replayed rollout rebuilds the same
    +    /// item the child originally received, instead of re-deriving it from current config.
    +    #[test]
    +    fn portable_plaintext_flag_round_trips_through_serde() {
    +        let communication = InterAgentCommunication::new_portable_plaintext(
    +            AgentPath::root(),
    +            AgentPath::root().join("worker").expect("recipient path"),
    +            Vec::new(),
    +            "task".to_string(),
    +            /*trigger_turn*/ true,
    +        );
    +        let serialized = serde_json::to_string(&communication).expect("serialize");
    +        let restored: InterAgentCommunication =
    +            serde_json::from_str(&serialized).expect("deserialize");
    +        assert_eq!(restored, communication);
    +
    +        // Default-off keeps old rollouts readable and the wire payload unchanged.
    +        let legacy = InterAgentCommunication::new(
    +            AgentPath::root(),
    +            AgentPath::root().join("worker").expect("recipient path"),
    +            Vec::new(),
    +            "task".to_string(),
    +            /*trigger_turn*/ true,
    +        );
    +        let encoded = serde_json::to_string(&legacy).expect("serialize");
    +        assert!(!encoded.contains("portable_plaintext"));
    +        assert!(!serde_json::from_str::<InterAgentCommunication>(&encoded)
    +            .expect("deserialize")
    +            .portable_plaintext);
    +    }
    +
         #[test]
         fn inter_agent_communication_response_input_item_preserves_commentary_phase() {
             let mut communication = InterAgentCommunication {
    @@ -4947,6 +5075,7 @@ mod tests {
                 encrypted_content: None,
                 internal_chat_message_metadata_passthrough: None,
                 trigger_turn: true,
    +            portable_plaintext: false,
             };
             communication.set_turn_id_if_missing("turn-1");
             let mut serialized_communication = communication.clone();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIconfigcustom-modelenhancementsubagent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions