@@ -40,7 +40,12 @@ func (e *Engine) runCommand(ctx context.Context, tool types.Tool, input string)
4040 return tool .BuiltinFunc (ctx , e .Env , input )
4141 }
4242
43- cmd , stop , err := e .newCommand (ctx , nil , tool .Instructions , input )
43+ var extraEnv []string
44+ if tool .WorkingDir != "" {
45+ extraEnv = append (extraEnv , "GPTSCRIPT_TOOL_DIR=" + tool .WorkingDir )
46+ }
47+
48+ cmd , stop , err := e .newCommand (ctx , extraEnv , tool .Instructions , input )
4449 if err != nil {
4550 return "" , err
4651 }
@@ -59,9 +64,6 @@ func (e *Engine) runCommand(ctx context.Context, tool types.Tool, input string)
5964 cmd .Stdin = strings .NewReader (input )
6065 cmd .Stderr = io .MultiWriter (all , os .Stderr )
6166 cmd .Stdout = io .MultiWriter (all , output )
62- if tool .WorkingDir != "" {
63- cmd .Dir = tool .WorkingDir
64- }
6567
6668 if err := cmd .Run (); err != nil {
6769 _ , _ = os .Stderr .Write (output .Bytes ())
@@ -82,10 +84,6 @@ func (e *Engine) newCommand(ctx context.Context, extraEnv []string, instructions
8284 envMap := map [string ]string {}
8385 for _ , env := range env {
8486 key , value , _ := strings .Cut (env , "=" )
85- key , ok := strings .CutPrefix (key , "GPTSCRIPT_VAR_" )
86- if ! ok {
87- continue
88- }
8987 envMap [key ] = value
9088 }
9189
0 commit comments