BuildersBuildAdd a function

Updated 28 Oct 2026View as Markdown

Add a function

Gives an agent a fixed pipeline of steps it calls as one tool, for the part of its work that must come out the same every time.

Skills for your coding agent

See it running: Trip planner, Add a new employee, Guided intake, Widget round trip, Plain HTML counter, Conversation list

Ask your coding agent#

Build a function that compares an invoice to its purchase order line by line and returns the differences, their total value and whether there are any. Test it on INV-4471 and on one invoice that matches, then give it to the invoice exceptions agent.

What gets built#

A function: a fixed list of steps the agent calls as one tool. A step calls an operation, calls a model through an AI model connection, works out a value, or chooses between values. Every step runs, and a function can't call another function. It's published as a version, and agents always use the published one.

What you decide#

  • Whether it's a function at all. It gives the same answer for the same input. Comparing an invoice to its purchase order qualifies. Deciding whether a difference is acceptable under the contract is a judgment, and stays with the agent.
  • What it returns. Return the value a script decides on, such as whether there are any differences.
  • Its test parameters. One set of inputs for each path, including one awkward case.
  • Whether it chooses by who the session is for. To answer differently per plan, region or account, read the label your backend set as attribution.<key>, never an input a caller could send. Give each label value its own test case with attribution set, plus one with no labels at all.
  • Which failures to retry. Retries are off unless you ask, up to 10 attempts in total.

A run an agent starts has a 300-second deadline and at most 1,000 outside calls. Limits has the rest.

Done when#

  • Its test parameters read Verified: every step ran.
  • It's published, and an active agent version holds it. Publishing is refused while it calls an untested operation, unless an admin chooses Go live untested.
  • The agent called it in a conversation and used what it returned.

See it working#

Live demoAsk your data · Northwind AnalyticsAsk sales questions and a dashboard draws the answers from what the agent’s functions return. Live demoStore assistant · Northwind OutdoorThe agent filters an outdoor store’s product grid, points at its pick and fills your basket.

In your repo#

Each function is a file in the agent's functions/ folder, holding the exact input create_resource takes. Your coding agent publishes a change once its test parameters pass. See Keep your agents in your code.

In the Studio#

Functions → New function opens the Function Builder. Describe the function and it writes the steps, which you can't edit by hand. Preview → Document writes the function out as prose, and Preview → Diagram runs it on Fixture input. Press Save changes, publish it on the Versions tab, then add it on the agent's Resources tab.