Capture Codex worker token usage

Record per-turn app-server token notifications so Live architecture benchmarks can compare context and cache costs.\n\nAI-assisted: OpenAI Codex.
This commit is contained in:
Paul Bakaus
2026-07-12 20:47:01 -07:00
parent 27bbf90ede
commit edde928736
2 changed files with 16 additions and 0 deletions
@@ -384,6 +384,7 @@ export class CodexAppServerClient {
let turnId = null;
let started = null;
let completed = null;
let tokenUsage = null;
const agentMessages = [];
const agentMessageCallbacks = [];
let firstAgentMessageAt = null;
@@ -407,6 +408,9 @@ export class CodexAppServerClient {
}
if (notificationTurnId !== turnId) return;
if (notification.method === 'turn/started') started = notification;
if (notification.method === 'thread/tokenUsage/updated') {
tokenUsage = notification.params?.tokenUsage || tokenUsage;
}
if (notification.method === 'item/completed'
&& notification.params?.item?.type === 'agentMessage'
&& typeof notification.params.item.text === 'string') {
@@ -456,6 +460,7 @@ export class CodexAppServerClient {
startResponse: result,
started,
completed,
tokenUsage,
status: completed?.params?.turn?.status || result.turn?.status || null,
agentMessages,
message: agentMessages.at(-1) || null,