Use an AI agent

Give an AI a task, files to read and tools to use, and get back an answer or the exact fields you ask for. Use it where the work has no fixed recipe.

A Run an AI agent step hands a task to an AI model. The agent works out which of its tools to use and when, then hands back an answer, or the exact fields you asked for, for the steps after it.

When to use an agent

Use an agent where the steps can't be known in advance:

  • Reading documents: pull the vendor, total and due date out of an invoice, a CV or a screenshot.
  • Judging: decide whether an email is a sales lead, or which of several pages answers a question.
  • Researching: work out who the business behind a bank-feed line is, deciding what to look at next from each search result.
  • Conversations: answer messages in a chat, remembering earlier turns.

When you already know the steps, such as search, then read, then write, build them as ordinary steps instead. An agent costs model usage on every run and can take a different path each time; ordinary steps run the same way every time at no extra cost.

Set up the step

Choose a model

Model sets which model runs the agent, from Anthropic, OpenAI, Google Gemini or another AI provider you've connected under Integrations. It runs on your own API key, so the provider bills your account; Lodol supplies the agent, not the model. Fallback model takes over if the first one fails to answer, for example during an outage.

Write the task and the instructions

Task is what to do on this run, written the way you'd brief a colleague and mentioning the values it needs: Find out who the vendor behind this bank line is: @line.description.

Instructions are the standing rules for every run: whose books these are, what counts as found, what to leave out.

Give it what it needs

Add Files for it to read, Tools for it to use, and Fields to return for the answer you want back. Each is described below.

Get fields back

Without Fields to return, the agent hands back its answer as text. With them, it must fill in each field before it finishes, and later steps read them by name, such as @triage.output.category.

Describe each field, including the answers you'll accept:

Fields to return
category  Exactly "urgent", "question" or "other"
reason    One sentence on why

This is how to branch on an AI's judgment: return a field, then test it with an If. Don't ask a model for a magic word in free text and then match the prose.

Read files

Files takes PDFs or images: a file you upload, a link, or a file an earlier step downloaded, such as Gmail's Download attachments. Up to 10 files, 20 MB in total. Reading files needs a model from Anthropic, OpenAI or Google Gemini.

To pull fields out of a document, give the agent the file and Fields to return, and no tools.

Tools

Tools are what the agent may use while it works:

  • Actions from your apps, such as a web search or reading a page. They run with your workspace's connections, so connect the app first.
  • Your own workflows: any published workflow that doesn't start from a trigger. The agent fills in its inputs and gets its outputs back, which is how to give it a fixed procedure, or another agent.

Keep the list short, two to four tools. For any input you don't want the agent to choose, such as which spreadsheet to write to, fix its value: it's filled in on every call and hidden from the agent.

Turn limit caps how many turns the agent takes before it must finish: 10 unless you change it, at most 30. Each turn is one model call and may use several tools.

Remember a conversation

For a workflow that answers messages, set Conversation key to something that identifies the conversation, such as the Slack thread or the sender's email address. Runs with the same key see what was asked and answered before; Runs to remember sets how many, 10 unless you change it, at most 50. Leave the key empty for one-off tasks, so each run starts fresh.

What the step returns

OutputWhat it holds
outputThe fields you asked for, filled in; or the agent's final text when you asked for none
textThe agent's final message
stepsHow many turns it took
tool_callsEach tool it used, with its input, whether it succeeded, and the start of what came back
modelThe model that finished the run
usageThe tokens the run used

Every field of the step is on the AI Agent reference page.

On this page