7
7
"io"
8
8
"net/http"
9
9
"os"
10
+ "slices"
10
11
"sort"
11
12
"strings"
12
13
"sync"
@@ -162,8 +163,12 @@ func (s *server) execHandler(w http.ResponseWriter, r *http.Request) {
162
163
reqObject .ChatState = "null"
163
164
}
164
165
165
- // Append a prompt URL for this run.
166
- reqObject .Env = append (reqObject .Env , fmt .Sprintf ("%s=http://%s/prompt/%s" , types .PromptURLEnvVar , s .address , runID ))
166
+ reqObject .Env = append (os .Environ (), reqObject .Env ... )
167
+ // Don't overwrite the PromptURLEnvVar if it is already set in the environment.
168
+ if ! slices .ContainsFunc (reqObject .Env , func (s string ) bool { return strings .HasPrefix (s , types .PromptURLEnvVar ) }) {
169
+ // Append a prompt URL for this run.
170
+ reqObject .Env = append (reqObject .Env , fmt .Sprintf ("%s=http://%s/prompt/%s" , types .PromptURLEnvVar , s .address , runID ))
171
+ }
167
172
168
173
logger .Debugf ("executing tool: %+v" , reqObject )
169
174
var (
@@ -179,7 +184,7 @@ func (s *server) execHandler(w http.ResponseWriter, r *http.Request) {
179
184
180
185
opts := & gptscript.Options {
181
186
Cache : reqObject .Options ,
182
- Env : append ( os . Environ (), reqObject .Env ... ) ,
187
+ Env : reqObject .Env ,
183
188
Workspace : reqObject .Workspace ,
184
189
CredentialContext : reqObject .CredentialContext ,
185
190
Runner : runner.Options {
0 commit comments