@@ -88,17 +88,16 @@ describe("createSandboxTools", () => {
8888 expect ( result . details ) . toMatchObject ( { exitCode : 0 } ) ;
8989 } ) ;
9090
91- it ( "returns structured error with exit code and stderr on non-zero exit " , async ( ) => {
91+ it ( "throws on non-zero exit so the framework reports a tool error " , async ( ) => {
9292 const tools = createSandboxTools ( { cwd : tmpDir } ) ;
9393 const bash = tools . find ( ( t ) => t . name === "bash" ) ! ;
9494
95- const result = await bash . execute ( "call-2" , {
96- command : "echo err >&2; exit 42" ,
97- } ) ;
98-
99- expect ( result . details . exitCode ) . toBe ( 42 ) ;
100- expect ( ( result as any ) . isError ) . toBe ( true ) ;
101- expect ( ( result . content [ 0 ] as any ) . text ) . toContain ( "err" ) ;
95+ // The framework only marks a tool call as `isError: true` when the
96+ // tool throws — returning `{ isError: true }` is ignored by
97+ // providers (notably Gemini). The bash tool must therefore raise.
98+ await expect (
99+ bash . execute ( "call-2" , { command : "echo err >&2; exit 42" } ) ,
100+ ) . rejects . toThrow ( / e r r | e x i t c o d e 4 2 / ) ;
102101 } ) ;
103102
104103 it ( "uses custom cwd when provided" , async ( ) => {
@@ -113,28 +112,24 @@ describe("createSandboxTools", () => {
113112 } ) ;
114113 } ) ;
115114
116- it ( "returns error result when cwd does not exist" , async ( ) => {
115+ it ( "throws when cwd does not exist" , async ( ) => {
117116 const tools = createSandboxTools ( {
118117 cwd : join ( tmpDir , "nonexistent-cwd" ) ,
119118 } ) ;
120119 const bash = tools . find ( ( t ) => t . name === "bash" ) ! ;
121120
122- const result = await bash . execute ( "call-4" , { command : "echo ok" } ) ;
123-
124- expect ( ( result as any ) . isError ) . toBe ( true ) ;
125- expect ( ( result . content [ 0 ] as any ) . text ) . toContain ( "ENOENT" ) ;
121+ await expect (
122+ bash . execute ( "call-4" , { command : "echo ok" } ) ,
123+ ) . rejects . toThrow ( / E N O E N T / ) ;
126124 } ) ;
127125
128- it ( "returns error result when command times out" , async ( ) => {
126+ it ( "throws when command times out" , async ( ) => {
129127 const tools = createSandboxTools ( { cwd : tmpDir } ) ;
130128 const bash = tools . find ( ( t ) => t . name === "bash" ) ! ;
131129
132- const result = await bash . execute ( "call-5" , {
133- command : "sleep 10" ,
134- timeout : 1 ,
135- } ) ;
136-
137- expect ( ( result as any ) . isError ) . toBe ( true ) ;
130+ await expect (
131+ bash . execute ( "call-5" , { command : "sleep 10" , timeout : 1 } ) ,
132+ ) . rejects . toThrow ( ) ;
138133 } ) ;
139134 } ) ;
140135
0 commit comments