Stamp conversation history items with creation times (#38272)

## What changed

- Add fractional Unix creation times to locally authored user, developer, agent, and tool-output items when they enter durable conversation history.
- Preserve any creation time already supplied with an item across subsequent requests, remote compaction, and resumed history.

## Testing

- Cover timestamp assignment and preservation in session, client, tool, agent-spawn, and remote-compaction tests.

GitOrigin-RevId: 431d1770b9746005c808bc0a43953845166d68ad
This commit is contained in:
ashwinnathan-openai authored and copyberry committed 2026-08-12 23:04:42 +00:00
1 parent 842fae26c9
commit 361fe2d202
10 files changed
+196 -22

No files matched your search

+7 -1
View File
@@ -1477,6 +1477,7 @@ async fn spawn_agent_can_fork_parent_thread_history_with_sanitized_items() {
ThreadHistoryMode::Legacy
);
let history = child_thread.session.clone_history().await;
let history_items = history.raw_items().cloned().collect::<Vec<_>>();
let mut expected_final_answer =
assistant_message("parent final answer", Some(MessagePhase::FinalAnswer));
expected_final_answer.set_turn_id_if_missing(&turn_context.sub_id);
@@ -1496,6 +1497,12 @@ async fn spawn_agent_can_fork_parent_thread_history_with_sanitized_items() {
internal_chat_message_metadata_passthrough: None,
};
expected_developer_message.set_turn_id_if_missing(&turn_context.sub_id);
expected_developer_message.set_create_time_if_missing(
history_items[1]
.executed_tool_call_metadata()
.and_then(|metadata| metadata.create_time.clone())
.expect("recorded developer message should have a creation timestamp"),
);
let expected_history = [
expected_parent_seed,
expected_developer_message,
@@ -1510,7 +1517,6 @@ async fn spawn_agent_can_fork_parent_thread_history_with_sanitized_items() {
internal_chat_message_metadata_passthrough: None,
},
];
let history_items = history.raw_items().cloned().collect::<Vec<_>>();
assert_eq!(
strip_response_item_ids(&history_items),
strip_response_item_ids(&expected_history),