Skip to content

chore: assign amsg_ IDs to agent messages - #29750

Merged
bolinfest merged 1 commit into
mainfrom
pr29750
Jun 24, 2026
Merged

chore: assign amsg_ IDs to agent messages#29750
bolinfest merged 1 commit into
mainfrom
pr29750

Conversation

@bolinfest

@bolinfest bolinfest commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Why

The ItemIds path fills in missing IDs before response items are persisted and emitted as raw item events. ResponseItem::AgentMessage is 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 InterAgentCommunication also need the generated ID to survive rollout persistence and resume. Otherwise clients can observe an amsg_ ID for the live raw response item, then see that same persisted agent message lose its item ID after restart.

What changed

  • Assign missing ResponseItem::AgentMessage IDs with the amsg_ prefix.
  • Persist the generated item ID on InterAgentCommunication and replay it back into the reconstructed ResponseItem::AgentMessage on resume.
  • Keep the persisted ID out of the model-visible inter-agent message envelope.
  • Keep CompactionTrigger and Other skipped because they do not get generated item IDs.
  • Update session/protocol tests for agent-message ID assignment and resume preservation.

Manual Testing

Run the local dev build using just c --enable item_ids to ensure this code is exercised:

if turn_context.config.features.enabled(Feature::ItemIds) {
Self::assign_missing_response_item_ids(items)
} else {

In the .jsonl file, 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_resume
  • just test -p codex-core record_inter_agent_communication_sets_turn_id_in_rollout_and_resume
  • just test -p codex-protocol inter_agent_communication_response_input_item_preserves_commentary_phase
@bolinfest bolinfest changed the title chore: ResponseItem::AgentMessage should be assigned an id with amsg_ prefix chore: assign amsg_ IDs to agent messages Jun 24, 2026
@bolinfest
bolinfest marked this pull request as ready for review June 24, 2026 00:23
@bolinfest
bolinfest requested a review from a team as a code owner June 24, 2026 00:23

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

@bolinfest
bolinfest merged commit 97dce07 into main Jun 24, 2026
47 of 62 checks passed
@bolinfest
bolinfest deleted the pr29750 branch June 24, 2026 00:57
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

2 participants