Skip to content

Commit 496fb38

Browse files
committed
fix: the tool name was not used in the prompt
When the next tool chats, the name is lost when the resp variable is reinitialized in the for loop. It always appeared to the user they were chatting with the main entrypoint tool. This changes it so the previous response is saved, and passed to the set prompt function. So now if a tool is communicating the user knows which tool is handling the chat turn. Signed-off-by: Bill Maxwell <[email protected]>
1 parent 838b300 commit 496fb38

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pkg/chat/chat.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ func Start(ctx context.Context, prevState runner.ChatState, chatter Chatter, prg
4141
}
4242
defer prompter.Close()
4343

44+
// We will want the tool name to be displayed in the prompt
45+
var prevResp runner.ChatResponse
4446
for {
4547
var (
4648
input string
@@ -53,7 +55,7 @@ func Start(ctx context.Context, prevState runner.ChatState, chatter Chatter, prg
5355
return err
5456
}
5557

56-
prompter.SetPrompt(getPrompt(prg, resp))
58+
prompter.SetPrompt(getPrompt(prg, prevResp))
5759

5860
if startInput != "" {
5961
input = startInput
@@ -79,5 +81,6 @@ func Start(ctx context.Context, prevState runner.ChatState, chatter Chatter, prg
7981
}
8082

8183
prevState = resp.State
84+
prevResp = resp
8285
}
8386
}

pkg/loader/github/github.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func getCommitLsRemote(ctx context.Context, account, repo, ref string) (string,
4141
}
4242

4343
// regexp to match a git commit id
44-
var commitRegexp = regexp.MustCompile("^[a-z0-9]{40}$")
44+
var commitRegexp = regexp.MustCompile("^[a-f0-9]{40}$")
4545

4646
func getCommit(ctx context.Context, account, repo, ref string) (string, error) {
4747
if commitRegexp.MatchString(ref) {

0 commit comments

Comments
 (0)