mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Expose response usage metadata in completion events (#41087)
## What changed - Parse optional `usage_metadata.amount` values from Responses API completion events without converting their string representation. - Propagate the metadata through SSE and WebSocket streams, regular turns, and remote compaction. - Add `usageMetadata` to the app-server `rawResponse/completed` notification and its generated schemas. ## Testing - Cover missing, null, zero, and high-precision amounts, including completion events emitted during compaction. GitOrigin-RevId: b16d81e8350eab0dc7ff613d0dc9dbed73041713
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use crate::error::ApiError;
|
||||
use codex_protocol::ResponseUsageMetadata;
|
||||
use codex_protocol::config_types::ReasoningSummary as ReasoningSummaryConfig;
|
||||
use codex_protocol::config_types::Verbosity as VerbosityConfig;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
@@ -113,6 +114,7 @@ pub enum ResponseEvent {
|
||||
Completed {
|
||||
response_id: String,
|
||||
token_usage: Option<TokenUsage>,
|
||||
usage_metadata: Option<ResponseUsageMetadata>,
|
||||
/// Did the model affirmatively end its turn? Some providers do not set this,
|
||||
/// so we rely on fallback logic when this is `None`.
|
||||
end_turn: Option<bool>,
|
||||
|
||||
Reference in New Issue
Block a user