Fluxon Docs
Batteries

reg — function registry

Store and call functions by their string name — essential for agent tools.

Storing and calling a function by its string name. Essential for agent tools: the AI gives you the tool name (text), and you must turn it into a function and call it.

reg.add "calc" \args -> args.a + args.b          # name → function
reg.add "search" \args -> http.get "/s?q=${args.q}"

out = reg.call "calc" {a:2 b:3}                  # call by name → 5
reg.has "search"                                  # is it in the registry → bool
reg.names                                         # a list of all names

Why is reg needed?

Otherwise, you would have to execute the tool name coming from the AI with match name (a hardcoded switch) — changing the code for each new tool. With reg, tools are added at runtime (reg.add), and the AI calls any of them with reg.call. You simply cannot build an agent platform without this.

See ai.run for the loop that produces the tool name and arguments.