You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If tracing or normalization logic is genuinely shared across multiple integrations, prefer adding it to `py/src/braintrust/integrations/utils.py` instead of copying it into each provider package. Avoid duplicating code between integrations unless there is a clear provider-specific reason the behavior must diverge.
109
+
108
110
Typical file ownership:
109
111
110
112
-`__init__.py`: export the integration class, `setup_<provider>()`, and public `wrap_*()` helpers
111
113
-`integration.py`: define the `BaseIntegration` subclass and register patchers
112
114
-`patchers.py`: define patchers and manual `wrap_*()` helpers
113
-
-`tracing.py`: keep provider-specific tracing, stream handling, normalization, and metadata extraction
115
+
-`tracing.py`: keep provider-specific tracing, stream handling, normalization, and metadata extraction; move cross-integration helpers to `py/src/braintrust/integrations/utils.py`
114
116
-`test_*.py`: keep provider behavior tests next to the integration
115
117
-`cassettes/`: keep VCR recordings next to the integration tests when the provider uses HTTP
Copy file name to clipboardExpand all lines: AGENTS.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,6 +75,12 @@ Root `Makefile` exists as a convenience wrapper. The authoritative SDK workflow
75
75
76
76
`py/noxfile.py` is the source of truth for compatibility coverage.
77
77
78
+
Testing preferences:
79
+
80
+
- Prefer VCR-backed integration tests with checked-in cassettes whenever practical.
81
+
- Avoid mocks, fakes, and heavily synthetic tests unless there is no reasonable cassette-based alternative or the code under test is truly internal/purely local.
82
+
- When fixing a bug or issue, default to a red/green workflow: first add or update a test that reproduces the problem and fails, then implement the fix, unless the user explicitly asks for a different approach.
83
+
78
84
Key facts:
79
85
80
86
-`test_core` runs without optional vendor packages.
@@ -87,6 +93,8 @@ When changing behavior, run the narrowest affected session first, then expand on
87
93
88
94
## VCR
89
95
96
+
VCR/cassette coverage is the default and preferred testing strategy for provider and integration behavior in this repo. Reach for cassette-backed tests before introducing mocks or fakes, and keep new coverage aligned with the existing VCR patterns unless there is a strong reason not to.
97
+
90
98
VCR cassette directories:
91
99
92
100
-`py/src/braintrust/cassettes/`
@@ -162,6 +170,7 @@ Avoid editing `py/src/braintrust/version.py` while also running build commands.
162
170
163
171
- Keep tests near the code they cover.
164
172
- Reuse existing fixtures and cassette patterns.
173
+
- Prefer extending an existing cassette-backed test over adding a new mock-heavy test.
165
174
- If a change affects examples or integrations, update the nearest example or focused test.
166
175
- For CLI/devserver changes, consider whether wheel-mode behavior also needs coverage.
167
176
- Do **not** add `from __future__ import annotations` unless it is absolutely required (e.g., a genuine forward-reference that cannot be resolved any other way). This import changes annotation evaluation semantics at runtime and can silently break `get_type_hints()`, Pydantic models, and other runtime introspection. Prefer quoted string literals (`"MyClass"`) or `TYPE_CHECKING` guards for forward references instead.
0 commit comments