[Platform] Add provider-level record/replay cassettes for test mocks#2129
Draft
wachterjohannes wants to merge 4 commits into
Draft
[Platform] Add provider-level record/replay cassettes for test mocks#2129wachterjohannes wants to merge 4 commits into
wachterjohannes wants to merge 4 commits into
Conversation
67693e1 to
c3fc67c
Compare
Contributor
|
You should check Symfony repo there is an open pull request for cassettes like this IIRC |
c3fc67c to
f0f7bc1
Compare
Contributor
Author
@OskarStark you mean symfony/symfony#63781 (RecorderHttpClient, php‑vcr‑style HAR record/replay)? Good catch. That one records at the HTTP boundary, so it overlaps with the sibling #2128, not this PR. This RecordingProvider sits a layer higher: it records the already‑converted ResultInterface returned by a ProviderInterface, so it's bridge‑agnostic, needs no http-client, and on replay it skips the converter entirely. Different trade‑off, complementary to a HTTP‑level recorder. I'll add a note to the PR cross‑referencing #63781 so the layering is clear. |
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.
Builds on / lands after #2123 (the
Mocktest provider). Sibling of #2128 (HTTP-boundary cassettes); both are independent and stack on #2123.Adds a provider-level record/replay tool for tests that only need a realistic, deterministic answer from a provider — without a network or API key.
Symfony\AI\Platform\Mock\Recording\RecordingProviderdecorates a realProviderInterface. By default the mode follows the cassette file:ResultInterfaceinto a JSONCassette, and returns it.Delete the cassette to re-record. The mode can be forced via the
recordconstructor argument (e.g.record: falsein CI to fail loudly instead of issuing a real request when a cassette is missing).ResultSerializersupports text, structured output (ObjectResult), embeddings (VectorResult), tool calls (ToolCallResult) and text streams. Interactions are matched by a signature over(model, input, options)and consumed FIFO.Scope note: on replay the recorded result is returned verbatim, so the bridge
ResultConverterruns only at record time. To exercise bridge internals (converter/formatter) offline, use the HTTP-boundary cassette (Mock\Http\CassetteHttpClient, #2128) instead. Result metadata and token usage are not preserved in this first version.Includes CHANGELOG entry, a docs subsection under Testing Tools, and offline tests (incl. an Anthropic record→replay demo). PHPUnit, PHPStan, php-cs-fixer and doctor-rst are green.