Repository navigation
Commit 63b8ed2
fix(anthropic): drop redundant bt_safe_deep_copy passes in tracing (#583)
## Summary
- `SpanImpl.log_internal` already runs `bt_safe_deep_copy` on every
logged event (see `logger.py:4699`), so the eager copies in
`_normalize_anthropic_input`, `_get_input_from_kwargs`, and
`_redact_server_tool_output` were duplicating work on every span
open/log.
- Removed the three `bt_safe_deep_copy` calls and dropped the now-unused
import. The remaining walks (`_normalize_anthropic_data`,
`_process_input_attachments`, inlined redaction) already build fresh
dicts/lists and never mutate user data, so behavior is preserved.
- Mirrors what `google_genai/tracing.py` does today and matches the
`sdk-integrations` skill guidance: "Do not over-serialize. Braintrust
serializes at send/log time."
## Test plan
- [x] `pytest src/braintrust/integrations/anthropic/test_anthropic.py`
on anthropic==0.116.0 (matrix `latest`) — 48 passed
- [x] `pytest src/braintrust/integrations/anthropic/test_anthropic.py`
on anthropic==0.48.0 — 39 passed, 9 legitimately skipped for features
unavailable on that version
- No cassettes re-recorded, no new mocks/fakes added — used the existing
VCR-backed tests
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- sfk:created-approved-by -->
Created by abhijeet
<!-- sfk:slack-thread -->
[Slack
thread](https://starfolkai.slack.com/archives/C0AQDETAVT3/p1784236089663339?thread_ts=1784236089.663339&cid=C0AQDETAVT3)
Co-authored-by: Starfolk <noreply@starfolk.ai>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent cb8323f commit 63b8ed2
1 file changed
Lines changed: 11 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
904 | 903 | | |
905 | 904 | | |
906 | 905 | | |
907 | | - | |
| 906 | + | |
908 | 907 | | |
909 | 908 | | |
910 | 909 | | |
| |||
1280 | 1279 | | |
1281 | 1280 | | |
1282 | 1281 | | |
1283 | | - | |
1284 | | - | |
| 1282 | + | |
1285 | 1283 | | |
1286 | | - | |
| 1284 | + | |
1287 | 1285 | | |
1288 | 1286 | | |
1289 | 1287 | | |
| |||
1343 | 1341 | | |
1344 | 1342 | | |
1345 | 1343 | | |
1346 | | - | |
1347 | | - | |
1348 | | - | |
1349 | | - | |
1350 | | - | |
1351 | | - | |
1352 | | - | |
1353 | | - | |
1354 | | - | |
1355 | | - | |
1356 | | - | |
1357 | | - | |
1358 | | - | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
1359 | 1352 | | |
1360 | 1353 | | |
1361 | 1354 | | |
| |||
0 commit comments