Skip to main content
Roast is a Ruby framework for building structured AI workflows from steps called cogs, such as chat, agent, ruby, and cmd. Braintrust traces each workflow run and each cog in it, including the LLM calls that chat cogs make.

Setup

Install the Braintrust and Roast gems, then configure your API keys. Roast integration requires Braintrust Ruby SDK v0.6.0 or later and roast-ai v1.0.0 or later, which requires Ruby 3.3 or later.
1

Install gems

Add the gems to your Gemfile:
Gemfile
Then install them:
2

Set environment variables

.env

Auto-instrumentation

To trace Roast workflows without modifying your workflow files, run the roast command through braintrust exec. Braintrust patches Roast when it loads, along with RubyLLM, which Roast’s chat cog uses to call models.
1

Create workflow.rb

This workflow passes a question from a ruby cog to a chat cog:
workflow.rb
2

Run the workflow

braintrust exec initializes Braintrust and logs to the project set by BRAINTRUST_DEFAULT_PROJECT.
To run workflows from your own Ruby code instead, load braintrust/setup before you require roast. When you call Roast::Workflow.from_file inside a span, the workflow’s span nests under it.
run_workflow.rb

Manual instrumentation

To trace Roast manually, initialize Braintrust with auto_instrument: false and enable instrumentation yourself with Braintrust.instrument!(:roast). Also call Braintrust.instrument!(:ruby_llm) to trace the LLM calls that chat cogs make.
run_workflow.rb

What Braintrust traces

Braintrust captures:
  • Workflow spans (roast.workflow), with the workflow file name in metadata (contrib.roast.workflow.name), plus the workflow’s targets, positional arguments, and keyword arguments as input when you pass them.
  • Cog spans (roast.cog.<name>), nested under the workflow span, with the cog’s type, name, and outcome (completed, failed, or skipped) in metadata. Cogs in a scope that a call cog runs nest under that cog’s span.
  • Cog output for ruby cogs that return a string, and the model response for chat cogs.
  • LLM call spans (ruby_llm.chat) for chat cogs, nested under the cog span, with the messages, model, response, and token usage that the RubyLLM integration records.
  • Errors, recorded on the cog span when a cog fails.

Resources