Carry per-input extension data to user message completion callbacks (#59455)

## What changed

Add `user_input_extension_data` to `TurnInputRequest` and carry it with each queued user input through completion, including inputs that steer an active turn. Expose the data to lifecycle contributors through `on_item_completed_with_metadata`, whose default implementation forwards to `on_item_completed` for compatibility. Keep this data out of model input and preserve the existing serialized input shape when no extension data is present.

## Testing

Add serialization round-trip coverage and extend the concurrent submission test to verify that inputs sharing a client ID retain their own metadata, report completion in the accepting turn, and omit extension data from model requests.

GitOrigin-RevId: f880cf812994a030cb1be9418280ba69e2885808
This commit is contained in:
Will Emmanuel
2026-11-04 17:13:00 +00:00
committed by copyberry
parent ede589336e
commit 031829da6a
8 changed files with 128 additions and 11 deletions
+4
View File
@@ -62,6 +62,9 @@ pub struct TurnInputRequest {
/// 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>,
/// Host-supplied, extension-keyed data for this user input's completion.
/// Travels with the individual input and is never included in model input.
pub user_input_extension_data: BTreeMap<String, Value>,
pub thread_settings: ThreadSettingsOverrides,
pub start: TurnStartOptions,
pub additional_context: BTreeMap<String, AdditionalContextEntry>,
@@ -120,6 +123,7 @@ impl TurnInputRequest {
Self {
input,
user_item_uuid: None,
user_input_extension_data: BTreeMap::new(),
thread_settings: ThreadSettingsOverrides::default(),
start: TurnStartOptions::default(),
additional_context: BTreeMap::new(),