From 2c6477b51a6204c6fefc3c3c19489e34794ff6ed Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Mon, 6 Jan 2025 15:21:25 -0500 Subject: [PATCH] fix: fix tool reference credentials that have sub tools The credential parsing was not correct for credentials in the sub tool format. This change fixes that parsing. Signed-off-by: Donnie Adams --- .../handlers/toolreference/toolreference.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/controller/handlers/toolreference/toolreference.go b/pkg/controller/handlers/toolreference/toolreference.go index b10338a39..ac76035a1 100644 --- a/pkg/controller/handlers/toolreference/toolreference.go +++ b/pkg/controller/handlers/toolreference/toolreference.go @@ -524,9 +524,14 @@ func modelName(modelProviderName, modelName string) string { } func determineCredentialNames(prg *gptscript.Program, tool gptscript.Tool, toolName string) ([]string, error) { - toolName, alias, args, err := gtypes.ParseCredentialArgs(toolName, "") + var subTool string + parsedToolName, alias, args, err := gtypes.ParseCredentialArgs(toolName, "") if err != nil { - return nil, err + parsedToolName, subTool = gtypes.SplitToolRef(toolName) + parsedToolName, alias, args, err = gtypes.ParseCredentialArgs(parsedToolName, "") + if err != nil { + return nil, err + } } if alias != "" { @@ -536,6 +541,9 @@ func determineCredentialNames(prg *gptscript.Program, tool gptscript.Tool, toolN if args == nil { // This is a tool and not the credential format. Parse the tool from the program to determine the alias toolNames := make([]string, 0, len(tool.Credentials)) + if subTool == "" { + toolName = parsedToolName + } for _, cred := range tool.Credentials { if cred == toolName { if len(tool.ToolMapping[cred]) == 0 {