braintrust-sdk
AGENTS.md30 starsChanged 16 days agoApache-2.0View on GitHub
TypeScript SDKs and integrations for Braintrust. Uses pnpm workspaces. Keep public exports minimal. Generally, export only the requested runtime APIs and do not export types unless explicitly requested. Our vendored Orchestrion implementation is purely internal to the Braintrust SDK. Downstream packages must not depend on its APIs, config schema, generated helpers, or compatibility with upstream Orchestrion. Do not expose these internals through SDK entrypoints or public configuration options. Change the transformer and its SDK callers together, and remove unused upstream…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository4 other files it gives its agents.
- create-changesetSkill
- create-pull-requestSkill
- e2e-testsSkill
- instrumentationSkill
The file
We split this AGENTS.md into the rules it gives an agent
10 rules. About 0 are common, 5 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 30
Keep public exports minimal.
- Distinctive: line 36
Do not expose these internals through SDK entrypoints or public configuration options.
- Distinctive: line 40
Use the normal Orchestrion config plus plugin/channel path by default.
- Very specific: line 43
Use defineInterceptor to define invocation hooks and intercept/invoke exclusively as generic wrapping machinery.
- Distinctive: line 45
Keep span creation, context propagation, and finalization in separate tracing functions.
- Very specific: line 47
Do not introduce combined APIs such as traceInvocation or interceptAndTrace, including internal convenience APIs.
- Very specific: line 68
Do not pass filters through pnpm test -- ....
- Distinctive: line 86
When adding or modifying e2e tests, run the relevant e2e verification twice before stopping so flakes are caught proactively.
- Very specific: line 100
Run from the repo root. Always run fix:formatting before committing — there is a pre-commit hook that will reject unformatted code.
- Very specific: line 111
When touching forked third-party code in this repository, including the vendored import-in-the-middle, require-in-the-middle, or …
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Braintrust JavaScript SDK Monorepo
TypeScript SDKs and integrations for Braintrust. Uses pnpm workspaces.
Repository Structure
.
├── js/ # Main `braintrust` package
├── integrations/ # Integration packages (@braintrust/*)
├── e2e/ # End-to-end scenario tests (mock server + subprocess isolation)
├── docs/ # Docs and reference material
└── internal/ # Internal test fixtures and golden projectsSetup
mise install # Install toolchain and dependenciesBuild
pnpm run build # Build all workspace packages (from repo root)Public API
Keep public exports minimal. Generally, export only the requested runtime APIs and do not export types unless explicitly requested.
Instrumentation
Our vendored Orchestrion implementation is purely internal to the Braintrust SDK. Downstream packages must not depend on its APIs, config schema, generated helpers, or compatibility with upstream Orchestrion. Do not expose these internals through SDK entrypoints or public configuration options. Change the transformer and its SDK callers together, and remove unused upstream features instead of retaining compatibility scaffolding. Preserve instrumented application behavior, coordination between SDK copies, and upstream license notices.
Use the normal Orchestrion config plus plugin/channel path by default. Special-case source patches should be rare exceptions only when the target SDK cannot be instrumented through the standard transformer path, and the reason should be documented next to the patch.
API wrapping and span instrumentation are separate concepts.
Use defineInterceptor to define invocation hooks and intercept/invoke exclusively as generic wrapping machinery.
Wrapping definitions and runtime code must not depend on spans, tracing lifecycle events, provenance, or SDK initialization.
Keep span creation, context propagation, and finalization in separate tracing functions.
Provider plugins explicitly register those functions through interceptors; tracing helpers accept callables and tracing configuration, never hooks or registration responsibilities.
Do not introduce combined APIs such as traceInvocation or interceptAndTrace, including internal convenience APIs.
Manual wrappers and generated wrappers only invoke hooks.
Instrumentation patches generally do not need to be removed during teardown. Prefer leaving behavior-preserving patches installed when they are idempotent; do not add unpatching machinery by default.
Span names should generally remain stable across calls and versions. Do not include dynamic values such as model names in span names; record those values in metadata instead.
Testing
Uses Vitest. Prefer running the narrowest relevant test rather than the full suite.
From js/ directory:
pnpm test # Core vitest suite (excludes wrappers)
pnpm exec vitest run src/foo.test.ts # Run a single test file
pnpm exec vitest run src/foo.test.ts -t "x" # Filter by test name within a file
pnpm run test:checks # Hermetic tests (core + vitest wrapper)
pnpm run check:typings # Typecheck source and test filesDo not pass filters through pnpm test -- ...; the -- makes Vitest ignore them and run the full suite.
Vitest does not typecheck. Before opening or updating a pull request, run pnpm run check:typings in each package you touched (or from the repo root) so type errors in source or test files are caught before CI.
E2E tests (e2e/):
Each scenario runs the SDK in a subprocess against a mock Braintrust server and snapshots the results. No API keys required for replay; recording needs provider keys.
Provider e2e tests must aim to exercise actual models with real, valid input data. Populate replay cassettes by recording actual provider responses. Do not substitute fabricated model responses or synthetic provider servers for this coverage. For multimodal scenarios, use valid image, audio, video, and document files. See the e2e testing skill for recording guidance.
For real-provider instrumentation tests and e2e recordings, default to cheap models that support the behavior under test, unless the user explicitly requests otherwise. Keep prompts, output limits, and media duration small while preserving meaningful coverage.
pnpm run test:e2e # Run all e2e scenarios (from repo root)
pnpm run test:e2e:update # Update e2e snapshots without re-recording cassettes
pnpm run test:e2e:record # Re-record provider cassettes and update snapshotsWhen adding or modifying e2e tests, run the relevant e2e verification twice before stopping so flakes are caught proactively. After running pnpm run test:e2e:update or pnpm run test:e2e:record, always run the normal e2e tests afterward to verify there is no snapshot drift or unstable output.
New instrumentation e2e coverage must test both a pinned SDK dependency and a separately named latest dependency alias for every supported version line. Only the latest alias should participate in test:e2e:bump; add pinned and latest variants to the CI e2e summary.
Span-tree snapshots are paired: *.span-tree.json is the structural contract, and *.span-tree.txt is the human-readable ASCII tree generated from the same normalized spans. Both files are asserted and should be updated together through pnpm run test:e2e:update or pnpm run test:e2e:record; do not hand-edit only one side of the pair.
From repo root:
pnpm run test # Run all workspace tests via turboLinting & Formatting
Run from the repo root. Always run fix:formatting before committing — there is a pre-commit hook that will reject unformatted code.
pnpm run formatting # Check formatting (prettier)
pnpm run lint # Run eslint checks
pnpm run fix:formatting # Auto-fix formatting
pnpm run fix:lint # Auto-fix eslint issuesVendored Forks and Licenses
When touching forked third-party code in this repository, including the
vendored import-in-the-middle, require-in-the-middle, or orchestrion-js
code, preserve and respect the upstream license requirements. Keep copyright
notices, license files, provenance notes, and js/NOTICE entries accurate when
copying, updating, or materially modifying vendored code.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

