Hello @loujiang, a few questions to understand the issue.
Does your workspace have serverless compute enabled?
When AI Playground calls your function as a tool, is there an active classic cluster attached ?
If you have a classic cluster, is it configured with Spark Connect enabled (which runtime, single-user or shared access mode)?
Is it a scalar function or a table-valued function?
Are you running as your personal user or through a service principal?
Does your user have USE CATALOG, USE SCHEMA, and EXECUTE on the function ?
Why I'm asking :
calling a SQL function directly via SQL uses a SQL warehouse.
But when AI Playground invokes it as a tool, it goes through Spark Connect — a completely different entry point that needs its own compute and auth.
Try
spark.sql("SELECT * from catalog.shema.my_function(arg)") in a notebook.