Persist agent messages as response items (#29829)

## Why

Inter-agent messages are recorded in live history as
`ResponseItem::AgentMessage`, but rollouts stored
`InterAgentCommunication` and rebuilt the response item during resume.
This made the rollout differ from the actual Responses history.

## What changed

- store the prepared `agent_message` response item directly
- keep `trigger_turn` in a small local metadata record for fork
truncation
- keep reading older `inter_agent_communication` rollout items
This commit is contained in:
jif authored and GitHub committed 2026-06-24 15:43:10 +01:00
1 parent f959e7fc98
commit b4f0f3eff1
19 files changed
+144 -17

No files matched your search

@@ -264,6 +264,7 @@ impl Session {
active_segment.get_or_insert_with(ActiveReplaySegment::default);
active_segment.counts_as_user_turn = true;
}
RolloutItem::InterAgentCommunicationMetadata { .. } => {}
RolloutItem::EventMsg(_) | RolloutItem::SessionMeta(_) => {}
}
@@ -320,6 +321,7 @@ impl Session {
turn_context.model_info.truncation_policy.into(),
);
}
RolloutItem::InterAgentCommunicationMetadata { .. } => {}
RolloutItem::Compacted(compacted) => {
if let Some(replacement_history) = &compacted.replacement_history {
// This should actually never happen, because the reverse loop above (to build rollout_suffix)