Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CodexCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class CodexCommands {
const accountText = this.formatAccountInfo(sessionState.account);
const tokenUsageText = this.formatTokenUsage(sessionState.totalTokenUsage);
const contextWindowText = this.formatContextWindow(
sessionState.totalTokenUsage,
sessionState.lastTokenUsage,
sessionState.modelContextWindow
);

Expand Down
2 changes: 1 addition & 1 deletion src/CodexEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export class CodexEventHandler {
private createUsageUpdate(params: ThreadTokenUsageUpdatedNotification): UpdateSessionEvent | null {
this.handleTokenUsageUpdated(params);

const used = this.sessionState.totalTokenUsage?.totalTokens;
const used = this.sessionState.lastTokenUsage?.totalTokens;
const size = this.sessionState.modelContextWindow;
if (used == null || size == null || size <= 0) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"sessionId": "test-session-id",
"update": {
"sessionUpdate": "usage_update",
"used": 2000,
"used": 1000,
"size": 128000
}
}
Expand All @@ -32,7 +32,7 @@
"sessionId": "test-session-id",
"update": {
"sessionUpdate": "usage_update",
"used": 3500,
"used": 1500,
"size": 128000
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"sessionId": "test-session-id",
"update": {
"sessionUpdate": "usage_update",
"used": 5000,
"used": 2500,
"size": 128000
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/CodexACPAgent/token-usage-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ describe('Token Usage Events', () => {
};
}

it('should emit usage_update with cumulative context usage', async () => {
it('should emit usage_update with latest turn usage as a context proxy', async () => {
const events = await setupPromptAndReturnEvents([
createTokenUsageNotification(sessionId, {
total: {
Expand All @@ -214,7 +214,7 @@ describe('Token Usage Events', () => {
await expect(`${JSON.stringify(events[0], null, 2)}\n`).toMatchFileSnapshot('data/token-usage-session-update.json');
});

it('should emit latest cumulative usage from multiple updates', async () => {
it('should emit latest turn usage from multiple updates', async () => {
const events = await setupPromptAndReturnEvents([
createTokenUsageNotification(sessionId, {
total: { totalTokens: 1000, inputTokens: 800, cachedInputTokens: 0, outputTokens: 200, reasoningOutputTokens: 0 },
Expand Down
Loading