- Trace Muse Code sessions to record session, turn, model call, tool, and subagent spans in Braintrust.
- Connect to Braintrust MCP to work with Braintrust projects, experiments, logs, and other data from Muse Code.
Braintrust tracing for Muse Code requires
bt v0.28.0 or later and Muse Code 1.3.0 or later.Trace Muse Code sessions
bt traces Muse Code sessions through Muse Code’s command hooks. There is no separate plugin to install.
Set up tracing
1
Install Muse Code
If you haven’t already, install Muse Code 1.3.0 or later. Make sure its
muse command is available in your terminal.2
Install and authenticate bt
Follow the
bt CLI quickstart to install bt, authenticate, and set your active context.3
Enable tracing
Run this command in a terminal:This command:
- Adds Braintrust hook entries for each Muse Code lifecycle event to the
hooksobject in$XDG_CONFIG_HOME/muse/settings.json(defaults to~/.config/muse/settings.json). Other hooks and settings in the file are preserved. - Writes
$XDG_CONFIG_HOME/muse/braintrust.json(defaults to~/.config/muse/braintrust.json), which records whether tracing is enabled and which project receives traces.
bt trace enable.4
Log a test trace
Muse Code loads hooks when a session starts, so start a new Muse Code session. Then ask Muse Code to do something simple. When the turn finishes, open your Braintrust project and confirm that the trace appears on the Logs page.
What Braintrust traces
Muse Code traces in Braintrust include:- Session spans with the session ID, local username, working directory, model, provider, permission mode, Muse Code version in
metadata.muse_version, Git repository metadata when available, the final response of the last completed turn, and token totals. - Turn spans with prompts and final responses. Turns that fail record the error.
- Model call spans with conversation input, tool definitions, response output, token metrics, and the finish reason, response ID, status, and request options in metadata.
- Tool spans with inputs, outputs, and errors, and the result in
metadata.tool_outcome. - Subagent spans with the subagent ID and child session ID.
- Context compaction spans, tagged
compaction, and permission request and notification spans, taggedpermission-requestandnotification.
braintrust.plugin.muse in context.span_origin. Each turn span and every span under it records the turn’s span ID in metadata.turn_span_id. bt sends pending spans at the end of each turn.
Common workflows
Use different tracing settings for one session
Use different tracing settings for one session
Use This workflow launches
bt trace run to trace a single Muse Code invocation without changing the saved tracing configuration:muse from the terminal. Set BRAINTRUST_MUSE_BIN to launch a different executable. bt adds its hooks to that invocation only and doesn’t send events through the hooks saved by bt trace enable, so the session isn’t traced twice.To change the saved destination, profile, or organization, rerun bt trace enable muse 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.Pass --tag ci --tag release-validation to either command to tag session spans.Trace a saved Muse Code session
Trace a saved Muse Code session
Use
bt trace import with muse and the session ID to import a past session, even if tracing was not enabled when it ran. Pass --all to import every saved session. bt reads sessions with muse export, so muse must be on your PATH, or set BRAINTRUST_MUSE_BIN to its path.Imported sessions include prompts, final responses, model calls with responses and token usage, and tool calls. They don’t include the conversation sent to each model call, and they have no subagent, compaction, permission request, or notification spans.To follow an active session, pass --attach with its session ID. Pressing Ctrl-C stops following the session without ending it. To record the rest of the session, attach again or import it after it finishes.To nest an imported session under an existing span or send it to an experiment, pass --parent or --destination to bt trace import.Resume a Muse Code session
Resume a Muse Code session
When you resume a Muse Code session, new turns are added to its existing Braintrust trace.
Stop tracing Muse Code sessions
Stop tracing Muse Code sessions
Use
bt trace disable muse to remove the Braintrust hook entries from Muse Code’s settings.json and delete its tracing configuration. Other hooks and saved bt profiles and credentials are preserved.Update the tracing hooks
Updatingbt also updates the Braintrust hooks in Muse Code’s settings. To update them, follow these steps:
1
Update bt
Follow the CLI migration guide to update
bt to the latest version and complete the applicable migrations.2
Update the hooks
bt trace update refreshes the Braintrust hook entries in Muse Code’s settings.json without changing your saved tracing configuration. If the hooks aren’t installed, run bt trace enable muse instead.3
Verify in a new session
Start a new Muse Code session, run a short task, and confirm that its trace appears on the Logs page in the intended Braintrust project.
Troubleshooting tracing
First, runbt trace doctor muse. The report warns when Muse Code is missing or earlier than 1.3.0, when bt isn’t on your PATH, and when the Braintrust hooks in settings.json are missing or outdated. Then, review the following:
Traces do not appear after setup
Traces do not appear after setup
Muse Code’s hooks run
bt by name, so confirm that bt is on the PATH of the environment that launches muse. If a Muse Code session was running when you enabled tracing, start a new session.Run bt trace doctor muse and confirm that tracing is enabled and routed to the intended project.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.Setup reports an unrecognized Braintrust forwarder
Setup reports an unrecognized Braintrust forwarder
bt trace enable muse and bt trace run muse stop with an error when Muse Code’s settings or managed hooks already contain a Braintrust forwarder, a bt trace hook command that bt didn’t write, so the session isn’t traced twice. Remove the manually added Braintrust hook entries and rerun the command.bt trace run muse also stops when a .muse/hooks.json file in the working directory or one of its parent directories already includes Braintrust tracing.Connect to Braintrust MCP
The Braintrust MCP server lets Muse Code query and update Braintrust data. MCP is configured independently from tracing.1
Choose authentication
- OAuth (recommended)
- API key
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.
- No Braintrust API key required
- No OAuth client ID or client secret to configure
/.well-known/oauth-authorization-server on the same host as your MCP endpoint (see next step), so a client can register itself.Your
bt login doesn’t authenticate the MCP server.2
Choose your endpoint
Use the endpoint for your organization’s data plane region:
Other connection details:
- Self-hosted: Copy the MCP URL from Settings > Data plane. This is your Braintrust API URL with
/mcpappended. - Transport: If your client asks you to choose a transport, choose HTTP (also called streamable HTTP). SSE-only clients can’t connect.
3
Add the server to Muse Code
Follow the Muse Code guide to add the remote server.
4
Verify the connection
To verify the connection, ask Muse Code to list your recent Braintrust projects. If it can’t connect, see Braintrust MCP troubleshooting.
5
Start using Braintrust tools
Muse Code can query logs, compare experiments, work with datasets, and use other Braintrust tools. For example:
- “Show me my recent Braintrust experiments.”
- “Query the last 10 logged requests with errors.”
- “Compare accuracy scores between my two latest experiments.”
Next steps
- Learn the CLI: See the full
bt tracereference. - Run evaluations: Follow the evaluation guide.
- Explore MCP tools: See the Braintrust MCP tool reference.
- Browse the source: View the coding-agent plugins repository.