@@ -16,14 +16,6 @@ const DEFAULT_SANDBOX: SandboxMode = "workspace-write";
1616const codexClient = new Codex ( ) ;
1717const threadCache = new Map < string , Thread > ( ) ;
1818
19- export const models = [
20- "gpt-5-codex" ,
21- "gpt-5.1-codex" ,
22- // "gpt-5",
23- // "o3",
24- // "o4-mini"
25- ] as const ;
26-
2719function sessionKey ( model : string , cwd : string ) : string {
2820 return `${ cwd } ::${ model } ` ;
2921}
@@ -67,7 +59,7 @@ function getOrCreateThread(model: string, cwd: string): Thread {
6759 return thread ;
6860}
6961
70- const codexAgent : Agent . Definition < ( typeof models ) [ number ] > = {
62+ const codexAgent : Agent . Definition = {
7163 async run ( model , prompt , options ) {
7264 options . logger . log (
7365 `codex-sdk --model ${ model } --sandbox ${ DEFAULT_SANDBOX } ${ prompt } ` ,
@@ -82,18 +74,24 @@ const codexAgent: Agent.Definition<(typeof models)[number]> = {
8274 try {
8375 const pricingKey = model ;
8476 const pricing = openai . models [ pricingKey ] ?. cost ;
77+ if ( ! pricing ) {
78+ options . logger . error (
79+ `No pricing info found for Codex model '${ pricingKey } '; reporting $0 cost.` ,
80+ ) ;
81+ }
8582 const turn = await thread . run ( prompt ) ;
8683 assert ( turn . usage , "The agent did not emit the usage information." ) ;
8784 usage = turn . usage ;
8885 const billableInput =
8986 ( usage . input_tokens ?? 0 ) - ( usage . cached_input_tokens ?? 0 ) ;
9087 const cachedInput = usage . cached_input_tokens ?? 0 ;
9188 const output = usage . output_tokens ?? 0 ;
92- cost =
93- ( billableInput * pricing . input +
94- output * pricing . output +
95- cachedInput * pricing . cache_read ) /
96- 1_000_000 ;
89+ cost = pricing
90+ ? ( billableInput * pricing . input +
91+ output * pricing . output +
92+ cachedInput * pricing . cache_read ) /
93+ 1_000_000
94+ : 0 ;
9795
9896 actions . push ( ...turn . items . map ( ( item ) => JSON . stringify ( item ) ) ) ;
9997 logTurnItems ( turn . items , options ) ;
0 commit comments