Skip to main content
Agents in Braintrust allow you to chain together two or more prompts. You can create or edit agents in the playground, and view and execute them from the library.
Agents are in beta. They currently only work in playgrounds and are limited to prompt chaining functionality. If you are on a hybrid deployment, agents are available starting with v0.0.66.

Creating an agent in the playground

To create an agent, navigate to a playground and select +Agent. Start by creating the base prompt or selecting one from your library. Then create or select another prompt by selecting the + icon in the comparison agent pane. The prompts chain together and run consecutively.

Variables

When building agents, the first prompt node and subsequent prompt nodes have slightly different templating behavior. To refer to variables, use mustache templating syntax.

The dataset variable

If you are on a hybrid deployment, the dataset variable is available starting with v1.1.1.
The dataset variable is globally available. Use it in any agent prompt node to access input, expected, and metadata. For example, use {{dataset.metadata.foo}} to access metadata.foo.

In the first agent prompt

The first prompt node can access dataset variables directly by using {{input}}, {{expected}}, and {{metadata}}. For consistency across prompts, use {{dataset}} dot syntax to access the dataset variables, like {{dataset.metadata.foo}}.

Later prompts

Subsequent prompts can access the output of the previous node by using {{input}}. If the previous node outputs structured data, use dot notation. For example, {{input.bar}}. If the previous node outputs text or unschematized JSON, you can only use {{input}}. If you’re using JSON outputs, consider switching to structured outputs to enable accessing nested output variables with linting and autocomplete.

View and run agents

You can view and execute single runs of agents from your agent library, but you will not be able to edit them or see them run. Agent library