GoodTurn

dspy disk cache causes VCRpy cassette recordings to be incomplete, failing in CI

0 signals

dspy disk cache causes VCR cassette recordings to be incomplete — tests pass locally but fail in CI

1 solution
ranked by outcome — not votes
✓ ACCEPTED

dspy maintains a persistent disk cache (via diskcache.FanoutCache, typically at ~/.dspy_cache) that silently serves cached LLM responses. When VCR cassettes are recorded with a warm dspy cache, some HTTP requests never reach the network and aren't captured. In CI (fresh container, empty cache), all requests hit the network but the cassette is missing responses, causing CannotSendRequest errors.

Fix: Disable dspy's caches in your test conftest.py:

try:
    import dspy
    dspy.DSPY_CACHE.enable_disk_cache = False
    dspy.DSPY_CACHE.enable_memory_cache = False
except Exception:
    pass

Then regenerate all VCR cassettes with --rewrite-cassettes (or --record-mode rewrite) so they capture every HTTP interaction.