@@ -2902,6 +2902,40 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => {
29022902 } ) . pipe ( Effect . scoped ) ,
29032903 ) ;
29042904
2905+ it . effect ( "leaves models unknown when a step ends without a seen start" , ( ) =>
2906+ Effect . gen ( function * ( ) {
2907+ const tokens = { input : 10 , output : 1 , reasoning : 0 , cache : { read : 0 , write : 0 } } ;
2908+ const step = ( id : string ) => ( { sessionID : SESSION , assistantMessageID : id } ) ;
2909+ const { runtime, thread } = yield * resumed ( [
2910+ out ( "session.prompt" , { sessionID : SESSION , text : "<any>" } ) ,
2911+ promptAccepted ,
2912+ event ( "session.step.started" , {
2913+ ...step ( "msg_seen" ) ,
2914+ agent : "build" ,
2915+ model : { id : "big-pickle" , providerID : "opencode" , variant : "default" } ,
2916+ started : 1 ,
2917+ } ) ,
2918+ event ( "session.step.ended" , { ...step ( "msg_seen" ) , finish : "tool-calls" , cost : 0 , tokens } ) ,
2919+ event ( "session.step.ended" , { ...step ( "msg_unseen" ) , finish : "stop" , cost : 0 , tokens } ) ,
2920+ event ( "session.execution.succeeded" , { sessionID : SESSION } ) ,
2921+ ] ) ;
2922+ const turn = yield * runtime . events . pipe (
2923+ Stream . filter (
2924+ ( event ) =>
2925+ event . type === "provider_turn.updated" && event . providerTurn . completedAt !== null ,
2926+ ) ,
2927+ Stream . runHead ,
2928+ Effect . forkScoped ,
2929+ ) ;
2930+ yield * runtime . startTurn ( turnInput ( thread ) ) ;
2931+ const settled = Option . getOrUndefined ( yield * Fiber . join ( turn ) ) ;
2932+ const usage =
2933+ settled ?. type === "provider_turn.updated" ? settled . providerTurn . turnTokenUsage : undefined ;
2934+ assert . deepInclude ( usage , { usageStatus : "complete" , inputTokens : 20 , outputTokens : 2 } ) ;
2935+ assert . notProperty ( usage , "models" ) ;
2936+ } ) . pipe ( Effect . scoped ) ,
2937+ ) ;
2938+
29052939 it . effect ( "reports cache writes as cache creation, not only as input" , ( ) =>
29062940 Effect . gen ( function * ( ) {
29072941 const { runtime, thread } = yield * resumed ( [
0 commit comments