@@ -2476,6 +2476,56 @@ it.layer(McpProviderSessions.layer)("OpenCode2 adapter", (it) => {
24762476 } ) . pipe ( Effect . scoped ) ,
24772477 ) ;
24782478
2479+ it . effect ( "stores a shell command that exits non-zero as failed" , ( ) =>
2480+ Effect . gen ( function * ( ) {
2481+ const tool = { sessionID : SESSION , assistantMessageID : "msg_assistant" , id : "call-exit" } ;
2482+ const { runtime, thread } = yield * resumed ( [
2483+ out ( "session.prompt" , { sessionID : SESSION , text : "<any>" } ) ,
2484+ promptAccepted ,
2485+ event ( "session.tool.input.started" , { ...tool , name : "shell" } ) ,
2486+ event ( "session.tool.called" , { ...tool , input : { command : "vp test" } , executed : false } ) ,
2487+ {
2488+ type : "emit_inbound" ,
2489+ frame : {
2490+ type : "sdk.event" ,
2491+ event : {
2492+ id : "evt_toolsuccess_call-exit" ,
2493+ created : 1 ,
2494+ type : "session.tool.success" ,
2495+ data : {
2496+ ...tool ,
2497+ content : [ { type : "text" , text : "1 failed\n" } ] ,
2498+ metadata : { status : "completed" , truncated : false , exit : 1 } ,
2499+ executed : false ,
2500+ } ,
2501+ durable : { aggregateID : SESSION , seq : 1 , version : 2 } ,
2502+ } ,
2503+ } ,
2504+ } ,
2505+ event ( "session.execution.succeeded" , { sessionID : SESSION } ) ,
2506+ ] ) ;
2507+ const events = yield * runtime . events . pipe (
2508+ Stream . takeUntil ( ( event ) => event . type === "turn.terminal" ) ,
2509+ Stream . runCollect ,
2510+ Effect . forkScoped ,
2511+ ) ;
2512+ yield * runtime . startTurn ( turnInput ( thread ) ) ;
2513+ const collected = yield * Fiber . join ( events ) ;
2514+ const item = collected
2515+ . flatMap ( ( event ) => ( event . type === "turn_item.updated" ? [ event . turnItem ] : [ ] ) )
2516+ . findLast ( ( item ) => item . nativeItemRef ?. nativeId ?. endsWith ( tool . id ) ) ;
2517+ assert . equal ( item ?. type , "command_execution" ) ;
2518+ assert . equal ( item ?. status , "failed" ) ;
2519+ assert . equal ( item ?. type === "command_execution" ? item . exitCode : null , 1 ) ;
2520+ assert . equal (
2521+ collected
2522+ . flatMap ( ( event ) => ( event . type === "node.updated" ? [ event . node ] : [ ] ) )
2523+ . findLast ( ( node ) => node . id === item ?. nodeId ) ?. status ,
2524+ "failed" ,
2525+ ) ;
2526+ } ) . pipe ( Effect . scoped ) ,
2527+ ) ;
2528+
24792529 it . effect ( "re-registers T3 MCP each turn and drops its instructions when adding fails" , ( ) =>
24802530 Effect . gen ( function * ( ) {
24812531 const mcpSessions = yield * McpProviderSessions . McpProviderSessions ;
0 commit comments