mirror of
https://github.com/openai/codex.git
synced 2026-11-07 20:30:33 +00:00
Expose assistant content token counts in completion notifications (#59041)
## What changed Add optional `contentTokenCount` metadata to `item/completed` notifications, carrying the producer-supplied token count for each completed assistant message in default and plan modes. Counts include any sampled footer and are `null` when unavailable. Keep this telemetry separate from stored thread items and omit it from subsequent model requests. Update the protocol schemas and generated TypeScript and Python types. ## Testing Add coverage for per-message counts, including zero, in default and plan modes; missing and malformed metadata; backward-compatible notification decoding; and exclusion from subsequent model requests. GitOrigin-RevId: 35973037a42650fa2d7569da8e88cb81215cf971
This commit is contained in:
@@ -3331,6 +3331,7 @@ mod tests {
|
||||
Event {
|
||||
id: "turn-1".to_string(),
|
||||
msg: EventMsg::ItemCompleted(ItemCompletedEvent {
|
||||
content_token_count: None,
|
||||
thread_id: conversation_id,
|
||||
turn_id: "turn-1".to_string(),
|
||||
item: CoreTurnItem::SubAgentActivity(SubAgentActivityItem {
|
||||
@@ -3503,6 +3504,7 @@ mod tests {
|
||||
state.track_current_turn_event(
|
||||
&event_turn_id,
|
||||
&EventMsg::ItemCompleted(ItemCompletedEvent {
|
||||
content_token_count: None,
|
||||
thread_id: conversation_id,
|
||||
turn_id: event_turn_id.clone(),
|
||||
item: CoreTurnItem::AgentMessage(CoreAgentMessageItem {
|
||||
@@ -3527,6 +3529,7 @@ mod tests {
|
||||
state.track_current_turn_event(
|
||||
&event_turn_id,
|
||||
&EventMsg::ItemCompleted(ItemCompletedEvent {
|
||||
content_token_count: None,
|
||||
thread_id: conversation_id,
|
||||
turn_id: event_turn_id.clone(),
|
||||
item: CoreTurnItem::AgentMessage(CoreAgentMessageItem {
|
||||
|
||||
Reference in New Issue
Block a user