@@ -435,6 +435,60 @@ it.layer(NodeServices.layer)("EventNdjsonLogger", (it) => {
435435 } ) ,
436436 ) ;
437437
438+ it . effect (
439+ "drops Claude thinking-token counters while keeping system and terminal usage records" ,
440+ ( ) =>
441+ Effect . gen ( function * ( ) {
442+ const tempDir = NodeFS . mkdtempSync ( NodePath . join ( NodeOS . tmpdir ( ) , "t3-provider-log-" ) ) ;
443+ const basePath = NodePath . join ( tempDir , "events.log" ) ;
444+ const threadId = ThreadId . make ( "claude-thinking-tokens" ) ;
445+ const counter = {
446+ direction : "incoming" ,
447+ stage : "decoded" ,
448+ payload : {
449+ type : "system" ,
450+ subtype : "thinking_tokens" ,
451+ estimated_tokens : 50 ,
452+ estimated_tokens_delta : 50 ,
453+ } ,
454+ } ;
455+ const retained = [
456+ { type : "system" , subtype : "init" , session_id : "claude-session" } ,
457+ {
458+ type : "stream_event" ,
459+ event : { type : "message_delta" , usage : { output_tokens : 10 } } ,
460+ } ,
461+ {
462+ type : "result" ,
463+ subtype : "success" ,
464+ usage : { output_tokens : 10 , output_tokens_details : { thinking_tokens : 5 } } ,
465+ } ,
466+ ] . map ( ( payload ) => ( { event : { direction : "incoming" , stage : "decoded" , payload } } ) ) ;
467+
468+ try {
469+ const store = yield * makeEventNdjsonLogStore ( basePath , { batchWindowMs : 0 } ) ;
470+ const native = store . logger ( "native" ) ;
471+ yield * native . write ( counter , threadId ) ;
472+ yield * native . write ( { provider : "claudeAgent" , event : counter } , threadId ) ;
473+ for ( const event of retained ) {
474+ yield * native . write ( event , threadId ) ;
475+ }
476+ yield * store . close ( ) ;
477+
478+ const records = NodeFS . readFileSync (
479+ ownedLogPath ( basePath , "claude-thinking-tokens" ) ,
480+ "utf8" ,
481+ )
482+ . trim ( )
483+ . split ( "\n" )
484+ . map ( ( line ) => decodeUnknownJson ( parseLogLine ( line ) . payload ) ) ;
485+ assert . deepEqual ( records , retained ) ;
486+ } finally {
487+ NodeFS . rmSync ( tempDir , { recursive : true , force : true } ) ;
488+ }
489+ } ) ,
490+ ) ;
491+
438492 it . effect ( "summarizes large histories without reading their items" , ( ) =>
439493 Effect . gen ( function * ( ) {
440494 const tempDir = NodeFS . mkdtempSync ( NodePath . join ( NodeOS . tmpdir ( ) , "t3-provider-log-" ) ) ;
0 commit comments