GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing docs.braintrust.dev — pi - Braintrust pi is a minimal terminal coding harness. You can connect it to Braintrust in two ways:
This page documents pi sessions with the Braintrust extension. To trace @earendil-works/pi-coding-agent SDK usage in your own application, see Pi Coding Agent SDK.Trace pi sessionsThe@braintrust/pi-extension extension uses bt to trace your pi sessions to Braintrust.
Set up tracingIf @braintrust/pi-extension is already installed, follow Update the tracing extension.1 Install pi If you haven’t already, install pi. The extension supports the latest patch release from each of the last five stable pi minor versions. 2 Install and authenticate bt Follow the bt CLI quickstart to install bt v0.19.3 or later, authenticate, and set your active context.3 Enable tracing Before starting pi, run this command in a terminal:
.braintrust.json can override the global tracing settings. See Share tracing settings in a repository.For more information, see bt trace enable.4 Restart pi Restart pi so it loads the extension and tracing settings. 5 Log a test trace Ask pi to do something simple. When the session finishes, open your Braintrust project and confirm that the trace appears on the Logs page. What Braintrust tracespi traces in Braintrust include:
braintrust.plugin.pi, along with versions in context.span_origin: the plugin version in version, the bt version in bt.version, and the pi version in pi.version. These versions are captured when each span is created, and unknown versions are null. Each turn span and every span under it records the turn’s span ID in metadata.turn_span_id.
Common workflows
Use different tracing settings for one session Use bt trace run to trace a single pi invocation without changing the saved tracing configuration.This workflow launches pi from the terminal.To change the saved destination, profile, or organization, rerun bt trace enable pi with the corresponding options. Running bt switch does not change the saved tracing configuration.To add root-span metadata, pass --additional-metadata '<JSON>' to bt trace run for one invocation or to bt trace enable for future sessions. Standard session metadata takes precedence when keys conflict.With bt v0.19.3 or later, pass --tag ci --tag release-validation to either command to tag session spans.
Share tracing settings in a repository A .braintrust.json file at the root of a Git repository applies tracing settings to every pi session started anywhere in that repository. Outside a Git repository, the extension reads .braintrust.json from the directory where pi starts. Repository tracing settings require @braintrust/pi-extension v2.3.0 or later.Commit the file to share settings such as the tracing switch, destination project, and metadata with your team. The file doesn’t store credentials, so each developer still needs the extension installed and bt authenticated.With bt v0.33.0 or later, run this command inside the repository to create or update the file:bt trace disable pi --scope project. The file is shared by the coding-agent integrations that support repository settings, so these commands change tracing for those agents too. For the full set of commands and merge rules, see Share tracing settings in a repository.Repository settings layer over the global tracing file:
route.span_plugins run after the global plugins, and their paths are relative to .braintrust.json. To run only the repository’s plugins, set "inherit_plugins": false.A repository’s .braintrust.json can name JavaScript span plugins that run on your machine when pi traces a session. Review the file and its plugins before you trace sessions in a repository you don’t control..braintrust.json isn’t valid JSON, or its route, inherit_plugins, or route.span_plugins value is invalid, the extension doesn’t trace sessions in that repository.
Configure the tracing status display In interactive sessions, pi shows Braintrust: connected in its status line while tracing is active. Once the session’s trace is available, the status becomes a Braintrust trace ↗ link that opens the trace in Braintrust. If pi doesn’t detect hyperlink support in your terminal, the status stays Braintrust: connected and doesn’t show the trace URL. Set PI_HYPERLINKS=1 to turn on links in a terminal that supports them but isn’t detected, or PI_HYPERLINKS=0 to turn them off. In Oh My Pi, the status stays Braintrust: connected and doesn’t show the trace link. Both the status and the trace link are enabled by default.To hide the status, set show_ui to false in the global tracing file or the repository’s .braintrust.json. To hide only the trace link, set show_trace_link to false. BRAINTRUST_SHOW_UI and BRAINTRUST_SHOW_TRACE_LINK override those settings.
Stop tracing pi sessions With bt v0.33.0 or later, bt trace disable pi pauses tracing and keeps the extension and its global tracing configuration. Run bt trace enable pi to resume.To uninstall the global tracing extension and remove its global tracing configuration, use bt trace uninstall pi. In earlier versions of bt, bt trace disable pi uninstalls them instead. Saved bt profiles and credentials are preserved. Restart pi after uninstalling.Project-local extension installations and repository .braintrust.json files are separate. Remove any project-local installation too if you want to stop tracing in that repository.Update the tracing extensionTo update the extension, follow these steps:If pi list shows @braintrust/pi-extension earlier than v2.0.0, or you cannot determine its version, follow Migrate from an older extension version. If it’s earlier than v2.3.0 and any repository has a .pi/braintrust.json file, also complete the @braintrust/pi-extension v2.3.0 section of that migration.1 Update bt Follow the CLI migration guide to update bt to the latest version and complete the applicable migrations.2 Update the tracing extension bt trace update updates the installed extension without changing your saved tracing configuration.3 Restart and verify pi Restart pi, run a short session, and confirm that its trace appears on the Logs page in the intended Braintrust project. Migrate from an older extension versionTo migrate to the latest version of the@braintrust/pi-extension extension, follow these steps:
1 Inspect your pi extensions Check whether @braintrust/pi-extension is installed:.pi/braintrust.json.If the extension is not installed, follow Set up tracing. If the output shows only a package version range and you cannot determine the installed version, complete both migration sections below. 2 Install or update bt These steps require bt v0.19.3 or later. Check whether bt is installed:
3 Complete version-specific migration steps Complete each section for a version newer than your starting @braintrust/pi-extension version, beginning with the oldest. If no sections apply, continue to the next step.
@braintrust/pi-extension v1.0.0 Complete this section if you started your migration from an extension version earlier than v1.0.0. bt handles both, and the tracing files store settings rather than credentials.Record project, org_name, and additional_metadata from ~/.pi/agent/braintrust.json and your project’s .pi/braintrust.json. Environment variables took precedence over these files. If the project was not configured, the default was pi.If the old configuration contains api_key, api_url, or app_url, use the corresponding credentials and deployment when you authenticate with bt. Keep credentials private and retain any settings needed by other integrations.
@braintrust/pi-extension v2.0.0 Complete this section if you started your migration from an extension version earlier than v2.0.0.
In the next step, pass the recorded project with --project, account and organization with --profile and --org, and metadata with --additional-metadata '<JSON>'. This preserves values that previously overrode your saved configuration.braintrust.json are resolved:
route object so you do not leave conflicting copies. Environment variables accepted by bt commands are separate from these extension changes. See bt trace.
@braintrust/pi-extension v2.3.0 Complete this section if you started your migration from an extension version earlier than v2.3.0. .pi/braintrust.json in the directory where pi started. Starting in v2.3.0, it reads them from .braintrust.json at the Git repository root and ignores .pi/braintrust.json.v2.3.0 also changes how project settings combine with global settings. Before v2.3.0, a project-level route object containing a destination replaced the entire global route object, and project-level additional_metadata replaced the global metadata. Starting in v2.3.0, objects merge field by field and arrays append to the global values. See Share tracing settings in a repository.For each repository with a .pi/braintrust.json file, move the settings you want to keep into .braintrust.json at the repository root, and then delete .pi/braintrust.json. Remove settings that only repeat the global file, because the repository file inherits them.4 Apply your tracing settings Run this command with your intended project, using the project you recorded earlier to preserve your destination: --profile <profile> and --org <organization> if needed to preserve your tracing account and organization. Otherwise, the command uses your active bt context, not your saved tracing settings.The command updates your global tracing file, normally ~/.pi/agent/braintrust.json. Check the following settings in that file:
.braintrust.json, keep only the settings that differ from the generated global file, using its route object as a template. The repository file inherits the rest. After moving any legacy values under route, remove their duplicate top-level keys so they cannot override it.5 Restart and verify pi Restart pi, run a short session, and confirm that its trace appears on the Logs page in the intended Braintrust project. Check each project where you changed local tracing settings. 6 Remove obsolete settings Complete this step only if you started with an extension version earlier than v2.0.0 and verified that traces reach the intended project in the previous step.
Settings used before @braintrust/pi-extension v2.0.0 The extension now reads tracing settings from its configuration files. Environment variables you previously configured for tracing may no longer be needed.Check these locations for leftover settings:
bt commands, MCP connections, or integrations still need:
BRAINTRUST_SHOW_UI and BRAINTRUST_SHOW_TRACE_LINK if you use them to control the tracing display.Troubleshooting tracingFirst, runbt trace doctor pi. Then, review the following:
The tracing extension is missing or disabled Run pi list and confirm that @braintrust/pi-extension is installed. If it is missing or broken, run:
Traces do not appear after setup If pi was running when its extension or configuration changed, restart it.Run bt trace doctor pi and confirm that tracing is enabled and routed to the intended project. Also inspect the repository’s .braintrust.json, which can override the global settings or turn off tracing. A .braintrust.json that isn’t valid JSON also turns off tracing in that repository.If authentication succeeds but traces do not appear, confirm that your account has permission to write logs to the selected project.For authentication, tracing destination, or endpoint problems, see bt trace troubleshooting and the CLI migration troubleshooting guide.Tracing failures do not interrupt the pi session.
pi uses an unexpected configuration directory The global tracing file remains at ~/.pi/agent/braintrust.json. Repository settings are read from .braintrust.json at the Git repository root, not from pi’s configuration directory. Extension versions earlier than v2.3.0 read .pi/braintrust.json instead.
Traces use unexpected settings Invocation settings supplied by bt trace run take precedence over the saved tracing configuration.For normal sessions, the repository’s .braintrust.json settings layer over the global settings. Objects merge field by field, arrays append, and other values replace the global values. See Share tracing settings in a repository.The extension does not use TRACE_TO_BRAINTRUST, BRAINTRUST_PROFILE, BRAINTRUST_ORG_NAME, BRAINTRUST_PROJECT, or BRAINTRUST_ADDITIONAL_METADATA from the agent’s environment to override the saved tracing settings.If an older file still has top-level additional_metadata, migrate it to route.additional_metadata and remove the old key so it cannot override your intended metadata.For environment variables accepted by the bt commands themselves, see bt trace.Connect to Braintrust MCPThe Braintrust MCP server lets pi query and update Braintrust data. MCP is configured independently from the tracing extension.1 Choose authentication
Use OAuth when your client supports it. Your client opens a Braintrust authorization page where you sign in and approve access. The server acts with the permissions of the account you sign in with.
/.well-known/oauth-authorization-server on the same host as your MCP endpoint (see next step), so a client can register itself.Use an API key for clients without OAuth support or for programmatic connections. The server acts with the permissions of the account the key belongs to.
Your bt login doesn’t authenticate the MCP server.2 Choose your endpoint Use the endpoint for your organization’s data plane region:
3 Add the server to pi MCP requires pi v1.0.0 or later. Earlier versions don’t include built-in MCP support.Follow the pi guide to add the remote server. 4 Verify the connection To verify the connection, ask pi to list your recent Braintrust projects. If it can’t connect, see Braintrust MCP troubleshooting. 5 Start using Braintrust tools pi can query logs, compare experiments, work with datasets, and use other Braintrust tools. For example:
Next steps
Was this page helpful? | ||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |