feat(adapters): mock + recording + replay adapters [closes #119]#293
Merged
EmersonBraun merged 1 commit intomainfrom Apr 15, 2026
Merged
feat(adapters): mock + recording + replay adapters [closes #119]#293EmersonBraun merged 1 commit intomainfrom
EmersonBraun merged 1 commit intomainfrom
Conversation
Phase 1, story #119. Three first-class testing primitives that let consumers test agent code without burning tokens or hitting real APIs. mockAdapter — deterministic adapter - Three call shapes: static chunks, request-aware function, or sequenced (different output per turn, looping when exhausted) - ADR 0001 compliant: pure factory (A1), auto-appends terminal 'done' if response doesn't include one (A3), abort safe (A6), no input mutation (A7) - Optional delayMs between chunks for streaming-UX testing - Optional history sink to capture every request received recordingAdapter — wrap a real adapter, capture every turn - Records {recordedAt, request, chunks} per stream - Pushes to a sink (in-memory or custom) - Drains the inner stream completely so partial recordings are impossible — fixtures are always whole replayAdapter — feed a fixture back as an adapter - Maps call N to fixture[N % fixture.length] - Throws on empty fixture (clear error vs silent misbehavior) inMemorySink — convenience for tests + ephemeral capture Use cases unlocked: - Unit-test agent flows without API keys or rate limits - Snapshot-test prompts: record a real session, replay forever in CI - Demo apps that need deterministic output for screenshots - Foundation for the deterministic-replay feature tracked in #134 Tests: - 12 new cases on @agentskit/adapters covering: static / request-aware / sequenced response, auto-done append, error termination (no double done), pure factory invariant, request history capture, abort cooperation, recordingAdapter end-to-end, replay determinism, empty fixture error - Total: 75 / 75 passing on @agentskit/adapters (was 63) Refs #119 #134 #211
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.
Summary
Phase 1 #119. Three testing primitives for adapters — write fast, deterministic tests without burning tokens.
mockAdapter— deterministic stubThree call shapes:
Conforms to ADR 0001 — auto-appends terminal
doneif the response doesn't include one, pure factory, abort-safe.recordingAdapter+replayAdapter— capture once, replay foreverRecordedTurnincludesrecordedAt, originalrequest, and every chunk yielded.This is the substrate for the deterministic-replay feature tracked in #134 (Phase 2).
Use cases unlocked
@agentskit/evaltest suitesTests
12 new cases — 75 / 75 passing on
@agentskit/adapters(was 63):Test plan
src/index.tsRecordedTurnis JSON-serializableRefs #119 #134 #211