mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
## 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
179 lines
4.1 KiB
JSON
Generated
179 lines
4.1 KiB
JSON
Generated
{
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
"definitions": {
|
|
"AbsolutePathBuf": {
|
|
"description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
|
|
"type": "string"
|
|
},
|
|
"ModelRequestStatus": {
|
|
"enum": [
|
|
"completed",
|
|
"failed",
|
|
"cancelled"
|
|
],
|
|
"type": "string"
|
|
},
|
|
"NullableString": {
|
|
"type": [
|
|
"string",
|
|
"null"
|
|
]
|
|
},
|
|
"SamplingKind": {
|
|
"enum": [
|
|
"sampling",
|
|
"foreground_compaction",
|
|
"background_compaction"
|
|
],
|
|
"type": "string"
|
|
},
|
|
"TokenUsage": {
|
|
"properties": {
|
|
"cache_write_input_tokens": {
|
|
"default": 0,
|
|
"format": "int64",
|
|
"type": "integer"
|
|
},
|
|
"cached_input_tokens": {
|
|
"format": "int64",
|
|
"type": "integer"
|
|
},
|
|
"input_tokens": {
|
|
"format": "int64",
|
|
"type": "integer"
|
|
},
|
|
"output_tokens": {
|
|
"format": "int64",
|
|
"type": "integer"
|
|
},
|
|
"reasoning_output_tokens": {
|
|
"format": "int64",
|
|
"type": "integer"
|
|
},
|
|
"total_tokens": {
|
|
"format": "int64",
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"required": [
|
|
"cached_input_tokens",
|
|
"input_tokens",
|
|
"output_tokens",
|
|
"reasoning_output_tokens",
|
|
"total_tokens"
|
|
],
|
|
"type": "object"
|
|
}
|
|
},
|
|
"oneOf": [
|
|
{
|
|
"properties": {
|
|
"hook_event_name": {
|
|
"enum": [
|
|
"PreModelRequest"
|
|
],
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"hook_event_name"
|
|
],
|
|
"type": "object"
|
|
},
|
|
{
|
|
"properties": {
|
|
"error": {
|
|
"$ref": "#/definitions/NullableString"
|
|
},
|
|
"hook_event_name": {
|
|
"enum": [
|
|
"PostModelRequest"
|
|
],
|
|
"type": "string"
|
|
},
|
|
"response_id": {
|
|
"allOf": [
|
|
{
|
|
"$ref": "#/definitions/NullableString"
|
|
}
|
|
],
|
|
"description": "The provider's identifier for the completed or incomplete response, if available."
|
|
},
|
|
"status": {
|
|
"$ref": "#/definitions/ModelRequestStatus"
|
|
},
|
|
"token_usage": {
|
|
"anyOf": [
|
|
{
|
|
"$ref": "#/definitions/TokenUsage"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"required": [
|
|
"error",
|
|
"hook_event_name",
|
|
"response_id",
|
|
"status",
|
|
"token_usage"
|
|
],
|
|
"type": "object"
|
|
}
|
|
],
|
|
"properties": {
|
|
"agent_id": {
|
|
"type": "string"
|
|
},
|
|
"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"
|
|
},
|
|
"kind": {
|
|
"$ref": "#/definitions/SamplingKind"
|
|
},
|
|
"model": {
|
|
"type": "string"
|
|
},
|
|
"request_id": {
|
|
"description": "Identifies a generation across harness retries and model fallback.",
|
|
"type": "string"
|
|
},
|
|
"session_id": {
|
|
"type": "string"
|
|
},
|
|
"thread_id": {
|
|
"description": "Identifies the issuing thread within its shared session.",
|
|
"type": "string"
|
|
},
|
|
"transcript_path": {
|
|
"$ref": "#/definitions/NullableString"
|
|
},
|
|
"turn_id": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"attempt_number",
|
|
"cwd",
|
|
"kind",
|
|
"model",
|
|
"request_id",
|
|
"session_id",
|
|
"thread_id",
|
|
"transcript_path",
|
|
"turn_id"
|
|
],
|
|
"title": "model-request.command.input",
|
|
"type": "object"
|
|
} |