Skip to content

Commit 0267454

Browse files
committed
Fix: make sure to not proceed with cred after abort
Signed-off-by: Daishan Peng <[email protected]>
1 parent cb3d0de commit 0267454

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Diff for: pkg/engine/engine.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import (
1717

1818
var maxConsecutiveToolCalls = 50
1919

20+
const AbortedSuffix = "\n\nABORTED BY USER"
21+
2022
func init() {
2123
if val := os.Getenv("GPTSCRIPT_MAX_CONSECUTIVE_TOOL_CALLS"); val != "" {
2224
if i, err := strconv.Atoi(val); err == nil && i > 0 {
@@ -335,7 +337,7 @@ func (e *Engine) Start(ctx Context, input string) (ret *Return, err error) {
335337
if ret.Result == nil {
336338
ret.Result = new(string)
337339
}
338-
*ret.Result += "\n\nABORTED BY USER"
340+
*ret.Result += AbortedSuffix
339341
default:
340342
}
341343
}()
@@ -501,7 +503,7 @@ func (e *Engine) Continue(ctx Context, state *State, results ...CallResult) (ret
501503
if ret.Result == nil {
502504
ret.Result = new(string)
503505
}
504-
*ret.Result += "\n\nABORTED BY USER"
506+
*ret.Result += AbortedSuffix
505507
default:
506508
}
507509
}()

Diff for: pkg/runner/runner.go

+4
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,10 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env
864864
continue
865865
}
866866

867+
if strings.HasSuffix(*res.Result, engine.AbortedSuffix) {
868+
continue
869+
}
870+
867871
if err := json.Unmarshal([]byte(*res.Result), &resultCredential); err != nil {
868872
return nil, fmt.Errorf("failed to unmarshal credential tool %s response: %w", ref.Reference, err)
869873
}

0 commit comments

Comments
 (0)