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