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 androast-ai v1.0.0 or later, which requires Ruby 3.3 or later.1
Install gems
Add the gems to your Gemfile:Then install them:
Gemfile
2
Set environment variables
.env
Auto-instrumentation
To trace Roast workflows without modifying your workflow files, run theroast 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.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 withauto_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, orskipped) in metadata. Cogs in a scope that acallcog runs nest under that cog’s span. - Cog output for
rubycogs that return a string, and the model response forchatcogs. - LLM call spans (
ruby_llm.chat) forchatcogs, 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.