Skip to content

tests(vcr): instrument Redis target + per-cassette persist log lines#26967

Draft
mateo-berri wants to merge 1 commit intolitellm_internal_stagingfrom
litellm_vcr-diagnostics-760e
Draft

tests(vcr): instrument Redis target + per-cassette persist log lines#26967
mateo-berri wants to merge 1 commit intolitellm_internal_stagingfrom
litellm_vcr-diagnostics-760e

Conversation

@mateo-berri
Copy link
Copy Markdown
Collaborator

Why

Stacked on top of #26838. We want to be able to answer three questions from a single CircleCI log:

  1. Which Redis instance is each xdist worker actually talking to?
  2. Are SET calls succeeding (or silently failing — noeviction will start refusing writes once memory fills)?
  3. Which tests result in cache hits vs misses vs no recording at all?

Right now the persister logs nothing, so all three of those are guesses.

What

Two diagnostic surfaces, both namespaced under the litellm.vcr.persister logger and prefixed with [VCR] so they're trivially grep-able (grep '\[VCR\]' build.log):

  1. log_redis_target_banner() — fires once per worker at pytest_recording_configure. Logs the resolved Redis URL (password masked), maxmemory_policy, used_memory_human, used_memory_peak_human, evicted_keys, and the current count of keys under the litellm:vcr:cassette: prefix.

  2. _RedisPersister.{load,save}_cassette — one [VCR] line per call: hit / miss / persist / persist-failed, with key, payload size, and episode count.

Sample output

Smoke-tested against the actual CI Redis (redis-19853.crce262.us-east-1-1.ec2.cloud.redislabs.com:19853):

[VCR] target=redis://default:***@redis-19853.crce262.us-east-1-1.ec2.cloud.redislabs.com:19853
[VCR] server maxmemory_policy=noeviction
[VCR] server used_memory_human=7.31M
[VCR] server used_memory_peak_human=1.7G
[VCR] server evicted_keys=0
[VCR] existing vcr keys under 'litellm:vcr:cassette:': 0
[VCR] persist key=litellm:vcr:cassette:tests/llm_translation/diagnostic_smoke/test_one bytes=334 episodes=1
[VCR] hit  key=litellm:vcr:cassette:tests/llm_translation/diagnostic_smoke/test_one bytes=334
[VCR] miss key=litellm:vcr:cassette:tests/llm_translation/diagnostic_smoke/missing

That output already confirms two things worth knowing about the target instance independent of this change:

  • maxmemory_policy=noeviction — once we hit maxmemory, every SET (VCR or otherwise) will start failing with OOM. There is nothing automatic that prunes our keys; the only pruning is the per-key 24h TTL set by save_cassette, and a successful SET resets that TTL.
  • used_memory_peak_human=1.7G — the instance has filled in the past, almost certainly during a previous llm_translation run.

Tests

tests/llm_translation/test_vcr_redis_persister.py (the existing 16 unit tests) still pass.

Type

🚄 Infrastructure
✅ Test

Slack Thread

Open in Web Open in Cursor 

…ines

Adds two diagnostic surfaces to the VCR Redis persister so we can verify
from CircleCI logs (a) which Redis instance a worker is actually pointed
at, (b) whether SETs are succeeding, and (c) which tests result in cache
hits vs misses vs no recording at all.

- log_redis_target_banner(): printed once per worker at
  pytest_recording_configure time. Reports the resolved URL (password
  masked), maxmemory_policy, used_memory(_human/_peak_human),
  evicted_keys, and the current count of keys under the
  litellm:vcr:cassette: prefix.

- _RedisPersister.{load,save}_cassette: emit one [VCR] log line per
  call (hit / miss / persist / persist-failed) tagged for trivial
  greppability in CircleCI build logs.

All output is namespaced under the 'litellm.vcr.persister' logger and
prefixed with [VCR] so it's easy to filter (`grep '\[VCR\]'`).

Existing unit tests in tests/llm_translation/test_vcr_redis_persister.py
still pass (16/16).

Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Bojun-Vvibe added a commit to Bojun-Vvibe/oss-contributions that referenced this pull request May 1, 2026
- BerriAI/litellm#26969: tool-permission guardrail tightening (merge-after-nits)
- BerriAI/litellm#26967: VCR Redis observability (merge-as-is)
- google-gemini/gemini-cli#26303: brain/critique role split + iteration (needs-discussion)
- google-gemini/gemini-cli#26287: voice transcription cursor-position insert (merge-after-nits)
- google-gemini/gemini-cli#26274: ssh:// extension install scheme (merge-as-is)
Base automatically changed from litellm_vcr-cassette-llm-tests-af37 to litellm_internal_staging May 1, 2026 22:16
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.

3 participants