Spring AI Test Tool Records LLM Responses for Fast, Free, Offline Replay
A developer has released an open-source library called spring-ai-test-tools that solves a key challenge in testing Spring AI applications: non-deterministic, slow, and costly calls to live language models. The tool works like the VCR pattern familiar from Ruby and Python testing — it records a real LLM interaction on the first test run and saves it as a local JSON cassette file. All subsequent test runs replay the cached response in under a millisecond, with no network access, no API tokens consumed, and no dependency on a GPU or provider credentials. The cache key is a SHA-256 hash of the exact request, ensuring fully deterministic replays, and a REPLAY_ONLY mode can be set in CI pipelines to fail loudly if any uncached live call is attempted. The library integrates transparently via Spring AI's ChatClientBuilderCustomizer, requiring no changes to existing test code.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in