Building UDFs for Agents
When you connect a canvas to AI, each visible UDF on it becomes a tool the agent can call. This page shows how Fused builds that tool from your UDF, so you can control what the agent sees.
How a UDF becomes a tool
| Tool | Comes from |
|---|---|
| Name | The UDF's name on the canvas, like nyc_meeting_routes. The function is always def udf, so the canvas name is what the agent sees. |
| Description | The UDF's description on the canvas (description in canvas.toml) if set, otherwise its docstring. With neither, the agent only sees a placeholder like UDF: udf_1 (auto). |
| Parameters | The typed arguments: str, int, float, bool and list become string, integer, number, boolean and array. A literal default is passed to the agent; a default read from a variable, like table: str = TABLE_NAME, is not. |
| Listed or not | Only visible UDFs are listed. Hidden UDFs still run when another UDF calls them. |
Every tool also takes format (the output format, like json) and cache_max_age.
To see the tools exactly as an agent does, open the canvas's OpenAPI spec at https://udf.ai/<fc_token>.api.json.
Make each tool easy to pick
- Name the UDF for what it answers, like
get_county_population, notudf_1ortest. - Describe what it does in the docstring, including what each parameter means. Parameters don't get their own descriptions, so the docstring is the only place the agent learns them.
- Type every parameter and give it a literal default, so the agent knows what to pass and can call the UDF without guessing.
Example
@fused.udf
def udf(state: str = "CA", top_n: int = 10):
"""
Returns the top_n counties in a US state by population.
state: two-letter state code, like "CA" or "NY"
top_n: number of counties to return
"""
import pandas as pd
df = pd.read_parquet("s3://my-bucket/census/counties.parquet")
return df[df["state"] == state].nlargest(top_n, "population")
Saved on the canvas as get_top_counties, this becomes a tool named get_top_counties with this docstring as its description and two optional parameters, state (string, default "CA") and top_n (integer, default 10).
Each call has a 120s limit and the agent waits for it. For longer work, start the job, return a job ID and add a separate UDF that reports its status. See Scaling out UDFs.
The agent decides what to pass. Never accept free-form SQL or table names, only read paths under a prefix you hardcode, and keep credentials out of parameters. See Write UDFs securely.
Expose your canvas to agents
Hide the UDFs an agent shouldn't call directly. In the top canvas below, the first two steps, gcal_today_events and gcal_events_geocode, are hidden, so the OpenAPI spec lists only nyc_meeting_routes. In the bottom canvas all three are visible, and the agent sees all three as tools.

All UDFs on a canvas share one token, so anyone with it can reach the UDFs on that canvas. Keep agent-facing UDFs on their own canvas, and heavy or destructive jobs on another.