feat: render typed envelopes for multi-agent v2 messages#28368
Merged
Conversation
Contributor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a0e1e3ca2b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ndering # Conflicts: # codex-rs/core/src/session/mod.rs # codex-rs/protocol/src/protocol.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Multi-agent v2 messages need a consistent, model-visible envelope that identifies what kind of interaction occurred, who sent it, and which agent it targets. Previously, encrypted deliveries exposed only
encrypted_content, while child completion used the legacy<subagent_notification>shape. That meant the client could not consistently presentNEW_TASK,MESSAGE, andFINAL_ANSWERusing the same format.This change adds the routing envelope as plaintext while keeping task and message payloads encrypted. No new Responses API field is required: an encrypted delivery is represented as an
input_textheader immediately followed by its existingencrypted_contentitem.Every envelope now follows this shape:
Message types
NEW_TASKNEW_TASKis used when the recipient should begin a new turn, including an initialspawn_agenttask and a laterfollowup_task.For a root agent spawning
/root/worker, the request contains a plaintext envelope followed by the encrypted task:{ "type": "agent_message", "author": "/root", "recipient": "/root/worker", "content": [ { "type": "input_text", "text": "Message Type: NEW_TASK\nTask name: /root/worker\nSender: /root\nPayload:\n" }, { "type": "encrypted_content", "encrypted_content": "<encrypted task payload>" } ] }Conceptually, the model receives:
MESSAGEMESSAGEis used for a queuedsend_messagedelivery. It communicates with an existing agent without starting a new turn.For
/root/workerreporting progress to the root agent, the request contains:{ "type": "agent_message", "author": "/root/worker", "recipient": "/root", "content": [ { "type": "input_text", "text": "Message Type: MESSAGE\nTask name: /root\nSender: /root/worker\nPayload:\n" }, { "type": "encrypted_content", "encrypted_content": "<encrypted message payload>" } ] }Conceptually, the model receives:
FINAL_ANSWERFINAL_ANSWERis emitted when a child agent reaches a terminal state and reports its result to its parent. Completion payloads are already available locally, so the complete envelope is represented as plaintext rather than as a plaintext header plus encrypted content.For
/root/workercompleting work for the root agent, the request contains:{ "type": "agent_message", "author": "/root/worker", "recipient": "/root", "content": [ { "type": "input_text", "text": "Message Type: FINAL_ANSWER\nTask name: /root\nSender: /root/worker\nPayload:\nNo regressions found." } ] }The model-visible form is:
Errored, shut down, and missing agents also use
FINAL_ANSWER, with a terminal-status description in the payload.What changed
NEW_TASKorMESSAGEinInterAgentCommunication::to_model_input_item, based on whether the encrypted delivery starts a turn.<subagent_notification>completion payload with a model-visibleFINAL_ANSWERenvelope.Task name,Sender, andPayloadconsistently in the multi-agent developer instructions.Legacy multi-agent behavior remains unchanged.
Verification
just test -p codex-protocoljust test -p codex-rollout-tracejust test -p codex-web-search-extensionjust test -p codex-core encrypted_multi_agent_v2_spawn_sends_agent_message_to_childjust test -p codex-core plaintext_multi_agent_v2_completion_sends_agent_messagejust test -p codex-core multi_agent_v2_followup_task_completion_notifies_parent_on_every_turnjust test -p codex-core multi_agent_v2_completion_queues_message_for_direct_parent