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
2026-06-24 15:43:10 +01:00
committed by GitHub
Unverified
parent f959e7fc98
commit b4f0f3eff1
19 changed files with 144 additions and 17 deletions
+8 -3
View File
@@ -2841,7 +2841,7 @@ impl Session {
std::slice::from_ref(&response_item),
);
let items = items.as_ref();
communication.id = items.first().and_then(ResponseItem::id).map(str::to_string);
let response_item = items[0].clone();
{
let mut state = self.state.lock().await;
state.record_items(
@@ -2849,8 +2849,13 @@ impl Session {
turn_context.model_info.truncation_policy.into(),
);
}
self.persist_rollout_items(&[RolloutItem::InterAgentCommunication(communication)])
.await;
self.persist_rollout_items(&[
RolloutItem::InterAgentCommunicationMetadata {
trigger_turn: communication.trigger_turn,
},
RolloutItem::ResponseItem(response_item),
])
.await;
self.send_raw_response_items(turn_context, items).await;
}