From 87a4de05dbe27bc3345073fe25c447a402129bdd Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Mon, 8 Sep 2025 13:17:59 -0700 Subject: [PATCH] token count --- codex-rs/core/src/codex.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index aa4d51cf6d..5cac6b94dd 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -1839,13 +1839,11 @@ async fn try_run_turn( st.token_info = info.clone(); info }; - sess.tx_event - .send(Event { - id: sub_id.to_string(), - msg: EventMsg::TokenCount(crate::protocol::TokenCountEvent { info }), - }) - .await - .ok(); + sess.send_event(Event { + id: sub_id.to_string(), + msg: EventMsg::TokenCount(crate::protocol::TokenCountEvent { info }), + }) + .await; let unified_diff = turn_diff_tracker.get_unified_diff(); if let Ok(Some(unified_diff)) = unified_diff { @@ -2920,13 +2918,11 @@ async fn drain_to_completed( info }; - sess.tx_event - .send(Event { - id: sub_id.to_string(), - msg: EventMsg::TokenCount(crate::protocol::TokenCountEvent { info }), - }) - .await - .ok(); + sess.send_event(Event { + id: sub_id.to_string(), + msg: EventMsg::TokenCount(crate::protocol::TokenCountEvent { info }), + }) + .await; return Ok(()); }