@@ -936,34 +936,46 @@ func TestParseOpenCodeDB_InvalidToolCall(t *testing.T) {
936936func TestParseOpenCodeDB_BashExitFailure (t * testing.T ) {
937937 tests := []struct {
938938 name string
939+ tool string
939940 state string
940941 wantErrored bool
941942 }{
942943 {
943944 name : "non-zero exit without exit-status text" ,
945+ tool : "bash" ,
944946 state : `{"input":{"command":"build"},"output":"error: command failed","metadata":{"exit":1}}` ,
945947 wantErrored : true ,
946948 },
947949 {
948950 name : "non-zero exit with empty output" ,
951+ tool : "bash" ,
949952 state : `{"input":{"command":"build"},"output":"","metadata":{"exit":127}}` ,
950953 wantErrored : true ,
951954 },
952955 {
953956 name : "zero exit is not a failure" ,
957+ tool : "bash" ,
954958 state : `{"input":{"command":"build"},"output":"ok","metadata":{"exit":0}}` ,
955959 wantErrored : false ,
956960 },
957961 {
958962 name : "metadata without an exit key is not a failure" ,
963+ tool : "bash" ,
959964 state : `{"input":{"command":"build"},"output":"ok","metadata":{"truncated":false}}` ,
960965 wantErrored : false ,
961966 },
962967 {
963968 name : "no metadata is not a failure" ,
969+ tool : "bash" ,
964970 state : `{"input":{"command":"build"},"output":"ok"}` ,
965971 wantErrored : false ,
966972 },
973+ {
974+ name : "non-bash metadata exit is not a failure" ,
975+ tool : "mcp_lookup" ,
976+ state : `{"input":{"query":"exit routes"},"output":"route 1","metadata":{"exit":1}}` ,
977+ wantErrored : false ,
978+ },
967979 }
968980
969981 for _ , tt := range tests {
@@ -979,7 +991,7 @@ func TestParseOpenCodeDB_BashExitFailure(t *testing.T) {
979991
980992 seeder .AddMessage ("msg_a" , "ses_bexit" , 1700000010000 , 1700000010000 , `{"role":"assistant"}` )
981993 seeder .AddPart ("prt_t" , "msg_a" , "ses_bexit" , 1700000010000 , 1700000010000 ,
982- `{"type":"tool","tool":"bash ","callID":"call_exit","state":` + tt .state + `}` )
994+ `{"type":"tool","tool":"` + tt . tool + ` ","callID":"call_exit","state":`+ tt .state + `}` )
983995
984996 sessions , err := parseOpenCodeAll (dbPath , "m" )
985997 require .NoError (t , err , "ParseOpenCodeDB" )
0 commit comments