Skip to content

Make braintrust.json the single source of tracing configuration - #27

Merged
Stephen Belanger (Qard) merged 3 commits into
mainfrom
t3code/fix-tracing-plugin-configuration
Aug 20, 2026
Merged

Make braintrust.json the single source of tracing configuration#27
Stephen Belanger (Qard) merged 3 commits into
mainfrom
t3code/fix-tracing-plugin-configuration

Conversation

@Qard

Copy link
Copy Markdown
Collaborator

Summary

Fixes the configuration precedence problem described in Tracing plugin configuration: problems and proposal.

Previously, precedence between braintrust.json and environment variables depended on which agent plugin you used:

  • Claude/Codex (bt trace hook): a route in braintrust.json made routing environment variables inert.
  • OpenCode/Pi: environment variables always overlaid braintrust.json, the opposite precedence.
  • All plugins: BRAINTRUST_ADDITIONAL_METADATA was read straight from the environment regardless of the above.

This implements the proposed fix: braintrust.json is now the only source of persistent tracing configuration (routing + enablement) for all four agents, and bt trace run is the only mechanism for a per-invocation override — with no plugin reading BRAINTRUST_PROFILE, BRAINTRUST_ORG_NAME, BRAINTRUST_PROJECT, TRACE_TO_BRAINTRUST, or BRAINTRUST_ADDITIONAL_METADATA directly.

Changes

  • bt-daemon: removed the clap env = "BRAINTRUST_*" fallbacks on hook, import, setup, and run arguments, and removed the TRACE_TO_BRAINTRUST environment fallback in AgentSettings::tracing_enabled.
  • OpenCode / Pi plugins: removed the environment-variable overlay for profile, org_name, project, trace_to_braintrust, and additional_metadata in config.ts; only the file and bt trace run's BT_TRACE_INVOCATION_SETTINGS can set these now. Plugin-local behavior toggles unrelated to routing (BRAINTRUST_DEBUG, BRAINTRUST_OPENCODE_ENABLE_TOOLS, BRAINTRUST_SHOW_UI, BRAINTRUST_SHOW_TRACE_LINK) are unchanged.
  • Docs: updated READMEs, .env.example, and install.sh across all four plugins to point at bt trace setup/bt trace run instead of environment variables for routing and metadata.
  • Removed a now-redundant .env_remove("BRAINTRUST_ADDITIONAL_METADATA") in the managed-run launcher and a hook-forwarder test block that encoded the old (now incorrect) env-based metadata contract.

Test plan

  • cargo test --all-features in bt-daemon (all passing, including pipeline/replay/translator integration suites)
  • cargo clippy --all-features --all-targets clean
  • pnpm vitest run for both the opencode and pi plugins (all passing, including updated precedence tests)
  • pnpm run check (format + lint + typecheck) clean for both plugins
  • make build-claude build-codex + bash scripts/test-hook-forwarders.sh dist passing
  • make build-opencode build-pi + validate.sh (includes a pnpm publish --dry-run) passing for both
  • Real end-to-end agent_integration.rs tests (claude_session_emits_traces, codex_session_emits_traces, opencode_session_emits_traces, pi_session_emits_traces) require the actual coding-agent CLIs on PATH and are #[ignore]d in this sandbox — verified by inspection that their test harness already drives routing via braintrust.json/bt trace run rather than the removed env vars, so behavior is unaffected, but CI should confirm.

🤖 Generated with Claude Code

Every tracing plugin previously mixed persistent config with direct
environment-variable reads, and Claude/Codex resolved that conflict
differently than OpenCode/Pi. Standardize on one rule across all four
agents: braintrust.json is the only source of persistent routing and
enablement, and `bt trace run` is the only per-invocation override.

- bt-daemon: drop the clap `env = "BRAINTRUST_*"` fallbacks on hook,
  import, setup, and run arguments, and stop falling back to
  `TRACE_TO_BRAINTRUST` when a persisted setting is absent.
- OpenCode and Pi plugins: stop overlaying BRAINTRUST_PROFILE,
  BRAINTRUST_ORG_NAME, BRAINTRUST_PROJECT, TRACE_TO_BRAINTRUST, and
  BRAINTRUST_ADDITIONAL_METADATA onto the loaded config file; only
  `bt trace run` invocation settings can override it, matching Claude
  and Codex.
- Update docs and examples across all four plugins to point at
  `bt trace setup`/`bt trace run` instead of environment variables.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

The test wrote the global braintrust.json config under
$HOME/.config/opencode, but index.ts resolves that directory from
XDG_CONFIG_HOME first. The GitHub Actions Linux runner sets that
variable, so the plugin looked for config in the wrong place and CI
failed while the same test passed locally.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Only the live hook dispatcher should be file-only, since it fires
automatically on every event with no user in the loop. `bt trace
setup`, `bt trace run`, and `bt trace import` are explicit, user-typed
commands, so restore their BRAINTRUST_PROFILE, BRAINTRUST_ORG_NAME,
BRAINTRUST_PROJECT, BRAINTRUST_DESTINATION, and
BRAINTRUST_ADDITIONAL_METADATA environment-variable fallbacks
alongside their flags.

- bt-daemon: re-add the clap `env = "BRAINTRUST_*"` attributes to
  SetupArgs, RunArgs, and ImportArgs. HookArgs keeps none. Split the
  standalone binary's route args into a hook-only RouteArgs (flags
  only) and a RunRouteArgs (flags + environment), sharing one
  `build_route` helper.
- Update docs across bt-daemon and the plugin READMEs to describe the
  corrected split.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Qard
Stephen Belanger (Qard) merged commit 50b4286 into main Aug 20, 2026
20 checks passed
@Qard
Stephen Belanger (Qard) deleted the t3code/fix-tracing-plugin-configuration branch August 20, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants