chore: Access params by maps for execute-sql tools (#1097)

It's safer and also more readable to access params by map.
This commit is contained in:
Wenxin Du
2025-08-06 16:42:02 -04:00
committed by GitHub
parent 99978bc697
commit 4fd19bf9af
6 changed files with 19 additions and 19 deletions

View File

@@ -120,10 +120,10 @@ type Tool struct {
}
func (t Tool) Invoke(ctx context.Context, params tools.ParamValues) (any, error) {
sliceParams := params.AsSlice()
sql, ok := sliceParams[0].(string)
paramsMap := params.AsMap()
sql, ok := paramsMap["sql"].(string)
if !ok {
return nil, fmt.Errorf("unable to get cast %s", sliceParams[0])
return nil, fmt.Errorf("unable to get cast %s", paramsMap["sql"])
}
// Log the query executed for debugging.
logger, err := util.LoggerFromContext(ctx)