Files
codex/codex-rs/app-server-protocol/schema/json/v2/RawResponseCompletedNotification.json
T
Dylan Hurd 1c9f890c05 Expose exact per-response usage in raw app-server events (#32985)
## Why

Clients that account for individual upstream Responses API calls need the exact
usage for each completion rather than accumulated or estimated thread usage.

## What changed

- Add the opt-in `rawResponse/completed` app-server notification with the
  `threadId`, `turnId`, `responseId`, and upstream `usage` payload.
- Emit the transient event for normal turns and compaction requests when
  `experimentalRawEvents` is enabled. The event is not persisted or replayed,
  and `usage` is `null` when the upstream response omits it.
- Export the notification in the app-server schemas and document its behavior.

## Testing

- Cover exact token breakdowns for turn and compaction completions.

GitOrigin-RevId: 49040a060bf1784c1ff1dd62112efb4a778428c4
2026-07-14 06:39:42 +00:00

66 lines
1.4 KiB
JSON
Generated

{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"TokenUsageBreakdown": {
"properties": {
"cachedInputTokens": {
"format": "int64",
"type": "integer"
},
"inputTokens": {
"format": "int64",
"type": "integer"
},
"outputTokens": {
"format": "int64",
"type": "integer"
},
"reasoningOutputTokens": {
"format": "int64",
"type": "integer"
},
"totalTokens": {
"format": "int64",
"type": "integer"
}
},
"required": [
"cachedInputTokens",
"inputTokens",
"outputTokens",
"reasoningOutputTokens",
"totalTokens"
],
"type": "object"
}
},
"description": "Internal-only notification containing the exact usage from one upstream Responses API completion.",
"properties": {
"responseId": {
"type": "string"
},
"threadId": {
"type": "string"
},
"turnId": {
"type": "string"
},
"usage": {
"anyOf": [
{
"$ref": "#/definitions/TokenUsageBreakdown"
},
{
"type": "null"
}
]
}
},
"required": [
"responseId",
"threadId",
"turnId"
],
"title": "RawResponseCompletedNotification",
"type": "object"
}