Add request IDs and attempt numbers to model request hooks (#61587)

## Why

Model request hooks need to correlate attempts belonging to the same generation across retries and model fallback.

## What changed

Add `request_id` and one-based `attempt_number` fields to `PreModelRequest` and `PostModelRequest` inputs and their generated schema. Keep the request ID stable across retries and increment the attempt number for each call to open a response stream.

## Testing

Extend hook tests to verify matching request IDs and increasing attempt numbers across retries. Extend the background compaction scenario to verify that its pre/post hooks share an ID distinct from the ordinary sampling request.

GitOrigin-RevId: 2d85ad6fd630505a89a712cebab6ca0f731610c9
This commit is contained in:
tongzhou wang
2026-11-15 00:39:00 +00:00
committed by copyberry
parent eaa25e1f43
commit 3b8bd2ee7e
5 changed files with 54 additions and 8 deletions
@@ -122,6 +122,10 @@ pub struct ModelRequestHookInput {
#[serde(skip)]
pub lifecycle_id: uuid::Uuid,
pub kind: SamplingKind,
/// Identifies a generation across harness retries and model fallback.
pub request_id: String,
/// One-based attempt number within this generation.
pub attempt_number: u32,
pub session_id: String,
/// Identifies the issuing thread within its shared session.
pub thread_id: String,