Conversation
amsg_ prefixamsg_ IDs to agent messages
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b6791c8aea
ℹ️ 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".
| ResponseItem::AgentMessage { .. } | ||
| | ResponseItem::CompactionTrigger { .. } | ||
| | ResponseItem::Other => continue, | ||
| ResponseItem::AgentMessage { .. } => "amsg", |
There was a problem hiding this comment.
Preserve agent-message IDs across resume
When Feature::ItemIds is enabled for inter-agent messages recorded through record_inter_agent_communication, this arm gives the live history/raw response item an amsg_ id, but the rollout still persists only RolloutItem::InterAgentCommunication; on resume, rollout_reconstruction.rs:316-320 rebuilds the item via to_model_input_item(), which sets id: None, and does not run this repair path. That means clients can observe an amsg_ id in rawResponseItem/completed before restart, then the same persisted agent message loses its stable item id after resuming the rollout.
AGENTS.md reference: AGENTS.md:L103-L111
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in the latest revision. record_inter_agent_communication() now copies the prepared ResponseItem::AgentMessage ID back onto the persisted InterAgentCommunication, and InterAgentCommunication::to_model_input_item() reuses that persisted ID when rollout resume reconstructs the agent message. The model-visible inter-agent envelope still strips the ID before serialization, while the rollout item keeps it. Added record_inter_agent_communication_preserves_item_id_in_rollout_and_resume to verify the rollout stores the same amsg_ ID and resumed history preserves it.
Why
The
ItemIdspath fills in missing IDs before response items are persisted and emitted as raw item events.ResponseItem::AgentMessageis part of that same response-item stream, but it was skipped by the missing-ID repair path, leaving agent messages without stable item IDs while messages and tool items received generated IDs.Agent messages recorded through
InterAgentCommunicationalso need the generated ID to survive rollout persistence and resume. Otherwise clients can observe anamsg_ID for the live raw response item, then see that same persisted agent message lose its item ID after restart.What changed
ResponseItem::AgentMessageIDs with theamsg_prefix.InterAgentCommunicationand replay it back into the reconstructedResponseItem::AgentMessageon resume.CompactionTriggerandOtherskipped because they do not get generated item IDs.Manual Testing
Run the local dev build using
just c --enable item_idsto ensure this code is exercised:codex/codex-rs/core/src/session/mod.rs
Lines 2713 to 2715 in 322e335
In the
.jsonlfile, I saw entries like:{ "timestamp": "2026-06-24T00:44:03.098Z", "type": "inter_agent_communication", "payload": { "id": "amsg_019ef715-849a-7a50-becc-ce63c6a9c994",Test plan
just test -p codex-core record_inter_agent_communication_preserves_item_id_in_rollout_and_resumejust test -p codex-core record_inter_agent_communication_sets_turn_id_in_rollout_and_resumejust test -p codex-protocol inter_agent_communication_response_input_item_preserves_commentary_phase