@@ -146,7 +146,7 @@ func TestEvaluateWithContext(t *testing.T) {
146
146
147
147
tool := ToolDef {
148
148
Instructions : "What is the capital of the united states?" ,
149
- Context : []string {
149
+ Tools : []string {
150
150
wd + "/test/acorn-labs-context.gpt" ,
151
151
},
152
152
}
@@ -345,6 +345,44 @@ func TestStreamRun(t *testing.T) {
345
345
}
346
346
}
347
347
348
+ func TestRestartFailedRun (t * testing.T ) {
349
+ shebang := "#!/bin/bash"
350
+ if runtime .GOOS == "windows" {
351
+ shebang = "#!/usr/bin/env powershell.exe"
352
+ }
353
+ tools := []ToolDef {
354
+ {
355
+ Instructions : "say hello" ,
356
+ Tools : []string {"my-context" },
357
+ },
358
+ {
359
+ Name : "my-context" ,
360
+ Type : "context" ,
361
+ Instructions : fmt .Sprintf ("%s\n exit ${EXIT_CODE}" , shebang ),
362
+ },
363
+ }
364
+ run , err := g .Evaluate (context .Background (), Options {DisableCache : true , GlobalOptions : GlobalOptions {Env : []string {"EXIT_CODE=1" }}}, tools ... )
365
+ if err != nil {
366
+ t .Fatalf ("Error executing tool: %v" , err )
367
+ }
368
+
369
+ _ , err = run .Text ()
370
+ if err == nil {
371
+ t .Errorf ("Expected error but got nil" )
372
+ }
373
+
374
+ run .opts .GlobalOptions .Env = nil
375
+ run , err = run .NextChat (context .Background (), "" )
376
+ if err != nil {
377
+ t .Fatalf ("Error executing next run: %v" , err )
378
+ }
379
+
380
+ _ , err = run .Text ()
381
+ if err != nil {
382
+ t .Errorf ("Error reading output: %v" , err )
383
+ }
384
+ }
385
+
348
386
func TestCredentialOverride (t * testing.T ) {
349
387
wd , err := os .Getwd ()
350
388
if err != nil {
0 commit comments