Skip to content

test: prune redundant integration tests and add unused-cassette checker - #802

Merged
Abhijeet Prasad (AbhiPrasad) merged 11 commits into
mainfrom
chore/prune-integration-tests
Sep 24, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 11 commits into
mainfrom
chore/prune-integration-tests

Conversation

@AbhiPrasad

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR removes low-value and redundant integration tests, adds a checker that finds cassette files no test reads, and pins sqlalchemy<2.1 so three nox sessions install again.

1. Prune redundant integration tests

  • Scope: reviewed every test file under integrations/, plus wrappers/test_langsmith_wrapper.py.
  • Removed: tests that were fully covered by a stronger test, that only restated constants or checked mocks, or that duplicated the subprocess auto_instrument() scripts.
  • Consolidated: near-duplicates became parametrized tests or share helpers (prompt-cache 5m/1h, claude-agent-sdk cancellation cases, ADK runner setup, langchain expected spans, genai sync/async tool use).
  • Assertions preserved: any assertion that only a deleted test made was moved into the test that replaces it first.
  • Kept on purpose: tests that look redundant at latest but cover a code path specific to an older version. For example, anthropic's streaming tests are the only coverage of the cache-token fallback on 0.48.0.
  • Size: about 2,960 net lines of test code removed, and 82 fewer tests at latest across the affected sessions (older matrix versions drop the same tests).
  • Cassettes: orphaned cassettes deleted, including 84 in pydantic_ai/cassettes/{0.1.9,1.0.1} that no session loads. Nothing was re-recorded.

2. scripts/check-unused-cassettes.py

  • Why: check-stale-cassettes.py only catches whole version directories that fall out of the matrix. This catches individual files inside valid directories: cassettes left behind by deleted or renamed tests, and cassettes for tests that always skip at a given version.
  • How it works: an audit hook in src/braintrust/_test_cassette_usage.py records every cassette file tests open. It is active only when BRAINTRUST_CASSETTE_USAGE_DIR is set.
    • This covers every loader (pytest-recording, the Claude Agent SDK transport, gRPC recordings, btx specs) and the auto-instrument subprocesses.
    • run <integrations|--all> runs every nox session that reads those cassettes, at every matrix version with CI=1, then reports files nothing opened. --clean deletes them.
    • If any session for an integration fails or is skipped, that integration is left out of the report instead of producing false positives.
  • Also added: make check-unused-cassettes INTEGRATIONS="…" and a section in AGENTS.md.
  • Validation:
    • Run on main for agentscope, pydantic_ai and instructor, it found exactly the 89 dead cassettes found by hand in part 1.
    • Run over every integration on this branch, it found 15 unversioned huggingface_hub/cassettes/*.yaml leftovers, deleted in this PR, and nothing else.

3. Pin sqlalchemy<2.1 for the dspy, google-adk and llama-index sessions

  • Problem: SQLAlchemy 2.1.0 ships only an sdist whose pyproject declares a duplicate normalized extra (mssql-pymssql), which uv refuses to build. test_dspy(2.6.0), test_google_adk(1.14.1) and both test_llamaindex versions failed to install.
  • Fix: a new test-sqlalchemy-2-0 constraint group, passed through the existing _install_matrix_dep(..., constraint_group) mechanism.
  • Lockfile: the uv.lock diff adds the new group; the only other changes are regenerated environment markers, and no locked package versions changed.

Test plan

  • Every affected session passes on every matrix version with CI=1 (replay-only VCR). CrewAI, LiveKit and Pipecat were run under Python 3.13, since they skip on 3.14.
  • src/braintrust/test_cassette_usage.py: tests for the recorder and checker logic. Deliberately breaking the recorder makes them fail.
  • ruff check, ruff format --check and pylint
  • check-unused-cassettes.py run --all: every integration reports no unused cassettes.

Notes

wrappers/test_langsmith_wrapper.py isn't run by any nox session or CI job: test_core ignores braintrust/wrappers. This PR doesn't change that.

🤖 Generated with Claude Code

Co-authored by StarfolkAI (@starfolkai)[bot]

…stral, cohere, huggingface_hub, instructor)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd util tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…assettes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…llamaindex, dspy, strands)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Records which cassette files tests actually open (via an audit hook enabled
by BRAINTRUST_CASSETTE_USAGE_DIR) and reports files no session reads.
Complements check-stale-cassettes.py, which only checks whole version dirs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ions

SQLAlchemy 2.1.0 ships only an sdist whose pyproject declares a duplicate
normalized extra (mssql-pymssql), which uv refuses to build. Installing
dspy (via optuna), google-adk and llama-index-core resolves it and fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nox always reads the per-version cassette directories; these base-dir
copies are never loaded (found with check-unused-cassettes.py).

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

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T21:15:36.141950Z 09f0204 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eeaf047e8e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread py/scripts/check-unused-cassettes.py Outdated
Comment thread py/scripts/check-unused-cassettes.py Outdated
- reuse find_spans_by_type / assert_metrics_are_valid / _find_agent_span
  instead of inline copies
- share one _method_refs builder in mistral tests; trim unused helper params
- drop the redundant install() in test_utils (braintrust.conftest covers it)
- load the recorder by path in its tests (no full SDK import per subprocess)
- checker: --reuse-venv flag, keep nox reports in the usage dir

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ttes run

A relative --usage-dir was resolved differently by test processes that run
from another cwd (e.g. pipecat's run_from_temp_dir), so nothing was recorded
and every cassette looked unused. Reusing a usage dir also merged stale reads
from earlier runs, hiding cassettes the current tests no longer open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 541291bb78

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread py/scripts/check-unused-cassettes.py
…ettes

A session can succeed while platform- or version-specific tests skip (e.g.
cursor's sync-bridge tests on Windows), leaving their cassettes unread. Tests
now log skips alongside cassette reads; unread files in a version directory
whose session skipped anything are listed with the skip reasons for review
instead of being reported as deletable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit 696d206 into main Sep 24, 2026
83 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the chore/prune-integration-tests branch September 24, 2026 21:46
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.

1 participant