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
@@ -130,6 +130,12 @@
"agent_type": {
"type": "string"
},
"attempt_number": {
"description": "One-based attempt number within this generation.",
"format": "uint32",
"minimum": 0.0,
"type": "integer"
},
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
},
@@ -139,6 +145,10 @@
"model": {
"type": "string"
},
"request_id": {
"description": "Identifies a generation across harness retries and model fallback.",
"type": "string"
},
"session_id": {
"type": "string"
},
@@ -154,9 +164,11 @@
}
},
"required": [
"attempt_number",
"cwd",
"kind",
"model",
"request_id",
"session_id",
"thread_id",
"transcript_path",