Allow background persistence for steered user input (#45506)

## Why

Persisting user input received during an active turn currently blocks the next model request. Stores that support background persistence can overlap this checkpoint with inference.

## What changed

- Add `PersistContext::SteeredUserInput` and `allows_background_persistence()` so stores may enqueue these checkpoints, with durability and error reporting enforced by later flush or shutdown operations.
- Use the new context for accepted steered user input and apply the same metadata handling as turn-start persistence.
- Keep tool outputs synchronous, including in mixed input batches, and allow stores to retain synchronous persistence for all contexts.

## Testing

Add gated-store integration tests covering background user-input persistence, synchronous stores, and synchronous tool-output checkpoints. Verify that the next request includes the steered input and waits for persistence when required.

GitOrigin-RevId: c60b7b6c9b483245fd3169306bcf0de248ccdf35
This commit is contained in:
Bryan Ashley authored and copyberry committed 2026-09-14 19:39:31 +00:00
1 parent 4d5d37c5f8
commit b9bfc0aff8
6 files changed
+293 -7

No files matched your search

+10 -2
View File
@@ -438,7 +438,7 @@ pub(crate) async fn run_turn(
&turn_context,
&turn_context.capture_current_model_info(),
&pending_input,
PersistContext::Standard,
PersistContext::SteeredUserInput,
)
.await
{
@@ -834,13 +834,21 @@ pub(crate) async fn run_hooks_and_record_inputs(
if matches!(input_item, TurnInput::UserInput { content, .. } if !content.is_empty()) {
accepted_user_input = true;
}
// Tool outputs retain their durability barrier, including in mixed input batches.
let input_persist_context = if persist_context == PersistContext::SteeredUserInput
&& matches!(input_item, TurnInput::FunctionCallOutput(_))
{
PersistContext::Standard
} else {
persist_context
};
record_pending_input(
sess,
turn_context,
model_info,
input_item.clone(),
hook_outcome.additional_contexts,
persist_context,
input_persist_context,
)
.await;
}