Repository navigation
LOU-D6: record/replay provider for deterministic tests against real model behavior - #67
Merged
Merged
Conversation
…odel behavior Adds recordReplay() to @loushy/build-ai-agent/testing: a VCR that wraps any LLMProvider, records every generate()/stream() exchange to a versioned JSON cassette and replays it with no network and no API key (lazy factory so the provider is never constructed in replay). Sequential-and-verified or by-request matching, CassetteMismatchError with a first-difference diff, volatile-value normalization, API-key redaction plus a custom redact hook, atomic writes after every recorded call, recorded errors and streams, usage preserved, auto mode. Documented in docs/testing.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
recordReplay(provider, options)in@loushy/build-ai-agent/testing: a VCRLLMProvider. Record once against a real model to a versioned JSON cassette, replay in CI with no network, key or peer package.Why
mockModelscripts turns by hand; this captures real model behavior (LOU-D6).How verified (merged origin/main 10f2d24)
npx tsc --noEmit: cleannpm run lint: 0 errors (433 warnings, same as main; none in new files)npm run build+ create-loushy-agent build: successnpm run test:coverage -- --testTimeout=30000: 121 files passed, 1751 passed, 4 skippednpm run fallow: exit 0 (0 above threshold)npm run test:types: 3 files, 10 tests passednpm run docs:verify-snippets: all 60 snippets type-check;npm run docs:llmsregenerated,docs:llms:checkokNotes for reviewer
save(); no exit hook. Each record session replaces the file.rawResponseand headers are never stored; only whitelisted request fields are written.--testTimeoutflakes on Windows (sandbox.test.tscold spawn,guardrails.test.tsEPERM cleanup) are unrelated to this change; I used a longer timeout locally.stream()is read to completion before returning (so chunks can be saved).🤖 Generated with Claude Code