-
Notifications
You must be signed in to change notification settings - Fork 300
fix: misc improvements related to creds and prompting #536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,13 @@ func SysPrompt(ctx context.Context, envs []string, input string, _ chan<- string | |
func sysPrompt(ctx context.Context, req types.Prompt) (_ string, err error) { | ||
defer context2.GetPauseFuncFromCtx(ctx)()() | ||
|
||
if req.Message != "" && len(req.Fields) == 1 && strings.TrimSpace(req.Fields[0]) == "" { | ||
_, _ = fmt.Fprintln(os.Stderr, req.Message) | ||
_, _ = fmt.Fprintln(os.Stderr, "Press enter to continue...") | ||
_, _ = fmt.Fscanln(os.Stdin) | ||
return "", nil | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes the prompt look a little bit better if all we want to do is display a message to the user instead of getting information from the user. |
||
|
||
if req.Message != "" && len(req.Fields) != 1 { | ||
_, _ = fmt.Fprintln(os.Stderr, req.Message) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -567,7 +567,7 @@ func (r *Runner) resume(callCtx engine.Context, monitor Monitor, env []string, s | |
Time: time.Now(), | ||
CallContext: callCtx.GetCallContext(), | ||
Type: EventTypeCallFinish, | ||
Content: getFinishEventContent(*state, callCtx), | ||
Content: getEventContent(*state.Continuation.Result, callCtx), | ||
}) | ||
if callCtx.Tool.Chat { | ||
return &State{ | ||
|
@@ -681,7 +681,7 @@ func streamProgress(callCtx *engine.Context, monitor Monitor) (chan<- types.Comp | |
CallContext: callCtx.GetCallContext(), | ||
Type: EventTypeCallProgress, | ||
ChatCompletionID: status.CompletionID, | ||
Content: message.String(), | ||
Content: getEventContent(message.String(), *callCtx), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to prevent credential tool output from leaking to the terminal. |
||
}) | ||
} else { | ||
monitor.Event(Event{ | ||
|
@@ -821,13 +821,13 @@ func (r *Runner) subCalls(callCtx engine.Context, monitor Monitor, env []string, | |
return state, callResults, nil | ||
} | ||
|
||
func getFinishEventContent(state State, callCtx engine.Context) string { | ||
// If it is a credential tool, the finish event contains its output, which is sensitive, so we don't return it. | ||
func getEventContent(content string, callCtx engine.Context) string { | ||
// If it is a credential tool, the progress and finish events may contain its output, which is sensitive, so we don't return it. | ||
if callCtx.ToolCategory == engine.CredentialToolCategory { | ||
return "" | ||
} | ||
|
||
return *state.Continuation.Result | ||
return content | ||
} | ||
|
||
func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env []string) ([]string, error) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.