Skip to content

LOU-D6: record/replay provider for deterministic tests against real model behavior - #67

Merged
LinuxDevil merged 4 commits into
mainfrom
lou-d6-record-replay
Oct 1, 2026
Merged

LinuxDevil merged 4 commits into
mainfrom
lou-d6-record-replay

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

What

recordReplay(provider, options) in @loushy/build-ai-agent/testing: a VCR LLMProvider. Record once against a real model to a versioned JSON cassette, replay in CI with no network, key or peer package.

Why

mockModel scripts turns by hand; this captures real model behavior (LOU-D6).

How verified (merged origin/main 10f2d24)

  • npx tsc --noEmit: clean
  • npm run lint: 0 errors (433 warnings, same as main; none in new files)
  • npm run build + create-loushy-agent build: success
  • npm run test:coverage -- --testTimeout=30000: 121 files passed, 1751 passed, 4 skipped
  • npm run fallow: exit 0 (0 above threshold)
  • npm run test:types: 3 files, 10 tests passed
  • npm run docs:verify-snippets: all 60 snippets type-check; npm run docs:llms regenerated, docs:llms:check ok

Notes for reviewer

  • Cassette is written atomically (temp + rename) after every recorded call, plus explicit save(); no exit hook. Each record session replaces the file.
  • Replay never calls a lazy factory; rawResponse and headers are never stored; only whitelisted request fields are written.
  • Default --testTimeout flakes on Windows (sandbox.test.ts cold spawn, guardrails.test.ts EPERM cleanup) are unrelated to this change; I used a longer timeout locally.
  • While recording, stream() is read to completion before returning (so chunks can be saved).

🤖 Generated with Claude Code

LinuxDevil and others added 4 commits October 1, 2026 10:31
…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>
@LinuxDevil
LinuxDevil merged commit d2cdf24 into main Oct 1, 2026
1 check passed
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