Setup
Installbraintrust alongside eve and set your Braintrust API key.1
Install packages
2
Set environment variables
.env
Manual instrumentation
To trace Eve agents, add Braintrust instrumentation to your Eve agent. The setup depends on your Eve version:- Eve 0.62 or later: Add one instrumentation file. See Eve 0.62 or later.
- Eve versions before 0.62: Add a hook and a root
instrumentation.tsfile. See Eve versions before 0.62.
Eve 0.62 or later
Eve 0.62 and later load instrumentation from files underagent/instrumentation/. Requires braintrust v3.37.0 or later.1
Add Braintrust instrumentation
Create a Braintrust instrumentation file. The Running
setup callback runs once per agent process and initializes the Braintrust logger:agent/instrumentation/braintrust.ts
eve add instrumentation/braintrust in your agent project creates this file.2
Build and run your agent
Build and start your Eve agent. The Eve runtime loads the instrumentation file automatically:
experimental: { instrumentationProviders: true } in defineAgent() in your agent.ts.Eve versions before 0.62
Eve versions before 0.62 load instrumentation from a rootinstrumentation.ts file. Register a Braintrust hook and instrumentation in your Eve agent. The hook handles the full span lifecycle; the instrumentation initializes the logger and captures LLM inputs for step spans.1
Add a Braintrust hook
Create a hook file in your agent’s hooks directory. Eve loads hook files automatically at startup:
hooks/braintrust.ts
2
Add Braintrust instrumentation
Create an instrumentation file in your agent’s instrumentation directory. The
setup callback runs once per agent process and initializes the Braintrust logger:instrumentation.ts
3
Build and run your agent
Build and start your Eve agent. The hook and instrumentation are loaded automatically by the Eve runtime:
What Braintrust traces
Braintrust captures:- Turn spans (
eve.turn), as individual traces, with the user message as input, the agent’s final response as output, and the session ID in metadata aseve.session_id. With the setup for Eve versions before 0.62, turn spans also have aggregated token metrics. - Parent-child nesting under the caller’s span, with the setup for Eve 0.62 or later, when the caller propagates W3C trace context to Eve. Eve forwards the caller’s
traceparentheader for session requests that include a remote subagentcallback. Requiresbraintrustv3.37.0 or later. - Step spans (
eve.step), as LLM spans nested under their turn, with the full message history as input, the model response as output, and model name and provider in metadata. - Tool call spans (named after the tool), as tool spans nested under their turn, with the tool arguments as input and the tool result as output.
- Subagent spans (named after the subagent), as tool spans nested under their turn, with the subagent’s turn spans nested under them.
- Token usage metrics (prompt, completion, total, prompt cached, and prompt cache creation) on step spans. With the setup for Eve versions before 0.62, step spans also have estimated cost when Eve reports it.
- Errors captured on every span.