Skip to content

Preserve assistant phase for replayed messages#19832

Merged
friel-openai merged 1 commit intomainfrom
fix/inter-agent-phase-recording
Apr 28, 2026
Merged

Preserve assistant phase for replayed messages#19832
friel-openai merged 1 commit intomainfrom
fix/inter-agent-phase-recording

Conversation

@friel-openai
Copy link
Copy Markdown
Contributor

Summary

This PR preserves ResponseItem::Message.phase when a message is converted through ResponseInputItem::Message, and records InterAgentCommunication::to_response_input_item() as MessagePhase::Commentary at the inter-agent message source.

The prior fork-based PR included unrelated Bazel workflow edits. This PR intentionally contains only the response-phase change.

Context

The OpenAI API deployment checklist says follow-up requests should preserve assistant phase: https://developers.openai.com/api/docs/guides/deployment-checklist#set-up-the-assistant-phase-parameter

We found this while debugging forked-agent prompt caching. Replayed inter-agent mailbox items could cross the ResponseInputItem::Message -> ResponseItem::Message boundary without their assistant phase, which made the same assistant history replay with different phases across resumed or forked sessions.

Validation

  • cd codex-rs && just fmt
  • cd codex-rs && cargo test -p codex-protocol
  • cd codex-rs && just fix -p codex-protocol
  • cd codex-rs && just fix -p codex-core
  • cd codex-rs && just argument-comment-lint

@friel-openai friel-openai requested a review from a team as a code owner April 27, 2026 16:15
@friel-openai friel-openai force-pushed the fix/inter-agent-phase-recording branch from d490430 to c3d92b1 Compare April 27, 2026 16:51
ResponseInputItem::Message can contain assistant-authored history that is later converted into ResponseItem::Message. Preserve phase across that boundary instead of inferring phase from message content.

InterAgentCommunication::to_response_input_item records inter-agent mailbox messages as commentary because they are assistant-authored in-between updates, not completed final answers.

This follows the assistant phase guidance in https://developers.openai.com/api/docs/guides/deployment-checklist#set-up-the-assistant-phase-parameter.

Co-authored-by: Codex <noreply@openai.com>
@friel-openai friel-openai force-pushed the fix/inter-agent-phase-recording branch from c3d92b1 to b2a6f1c Compare April 27, 2026 17:19
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm after my comment

content: vec![ContentItem::OutputText {
text: serde_json::to_string(self).unwrap_or_default(),
}],
phase: Some(MessagePhase::Commentary),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this that locks it and make sure we don't have regressions?

@friel-openai friel-openai merged commit 598bbcd into main Apr 28, 2026
53 of 76 checks passed
@friel-openai friel-openai deleted the fix/inter-agent-phase-recording branch April 28, 2026 15:46
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 28, 2026
@friel-openai
Copy link
Copy Markdown
Contributor Author

@codex add a test to address @jif's comment

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants