Preserve host-assigned user input IDs in Responses messages (#57538)

## What changed

Add optional `TurnInputRequest.user_item_uuid` and carry it through turn starts and steering to the recorded user message. When supplied, use `msg_input_<uuid>` as the Responses item ID; inputs without a UUID retain generated IDs. Raw response items ignore this field.

Add `ResponseItemId` helpers to construct and recognize the reserved `msg_input_` namespace.

## Testing

Add regression coverage for steered inputs with identical text and client IDs, checking that each supplied UUID survives recording and UI item IDs remain distinct. Add a scenario test verifying that the assigned ID reaches Responses and persists in subsequent request history alongside an identical ordinary prompt.

GitOrigin-RevId: 440e306bfdaa7facb69b21930c5244a83db2fdae
This commit is contained in:
Zack Brunson
2026-10-27 19:00:03 +00:00
committed by copyberry
parent 4d3ed3f3b4
commit e3149ddb11
8 changed files with 222 additions and 14 deletions
+10
View File
@@ -25,6 +25,16 @@ impl ResponseItemId {
Self(format!("{prefix}_{suffix}"))
}
/// Reserved for physical user inputs admitted by the host. Raw item
/// ingestion must reject this namespace when it accepts caller-supplied IDs.
pub fn for_admitted_user_input(uuid: uuid::Uuid) -> Self {
Self::with_suffix("msg_input", uuid)
}
pub fn is_admitted_user_input(&self) -> bool {
self.0.starts_with("msg_input_")
}
pub fn from_server(value: String) -> Self {
Self(value)
}
+4
View File
@@ -59,6 +59,9 @@ pub struct ResponseItemAnnotations {
#[derive(Clone, Debug)]
pub struct TurnInputRequest {
pub input: TurnInput,
/// Optional host-assigned UUID for the Responses message created from [`TurnInput::UserInput`].
/// Ignored for all other inputs, including raw user-role Responses items.
pub user_item_uuid: Option<uuid::Uuid>,
pub thread_settings: ThreadSettingsOverrides,
pub start: TurnStartOptions,
pub additional_context: BTreeMap<String, AdditionalContextEntry>,
@@ -116,6 +119,7 @@ impl TurnInputRequest {
pub fn new(input: TurnInput) -> Self {
Self {
input,
user_item_uuid: None,
thread_settings: ThreadSettingsOverrides::default(),
start: TurnStartOptions::default(),
additional_context: BTreeMap::new(),