feat: phase 2 usage (#12121)

This commit is contained in:
jif-oai
2026-02-18 11:33:55 +00:00
committed by GitHub
parent f0ee2d9f67
commit 2293ab0e21
5 changed files with 56 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ use crate::thread_manager::ThreadManagerState;
use codex_protocol::ThreadId;
use codex_protocol::protocol::Op;
use codex_protocol::protocol::SessionSource;
use codex_protocol::protocol::TokenUsage;
use codex_protocol::user_input::UserInput;
use std::path::PathBuf;
use std::sync::Arc;
@@ -153,6 +154,16 @@ impl AgentControl {
Ok(thread.subscribe_status())
}
pub(crate) async fn get_total_token_usage(&self, agent_id: ThreadId) -> Option<TokenUsage> {
let Ok(state) = self.upgrade() else {
return None;
};
let Ok(thread) = state.get_thread(agent_id).await else {
return None;
};
thread.total_token_usage().await
}
fn upgrade(&self) -> CodexResult<Arc<ThreadManagerState>> {
self.manager
.upgrade()