SnapshotAgent: Add normalizeBody and normalizeQuery#5121
Merged
mcollina merged 1 commit intoMay 5, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5121 +/- ##
==========================================
- Coverage 93.28% 93.27% -0.01%
==========================================
Files 110 110
Lines 36313 36350 +37
==========================================
+ Hits 33873 33906 +33
- Misses 2440 2444 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d047f55 to
c1e7ba2
Compare
mcollina
reviewed
May 4, 2026
Member
mcollina
left a comment
There was a problem hiding this comment.
Can you add a test for the types changes?
Adds two new options to SnapshotAgent and SnapshotRecorder for partial request matching: - `normalizeBody(body)` — normalizes the request body before hashing, e.g. to strip volatile fields like timestamps from JSON payloads - `normalizeQuery(params)` — normalizes query parameters (as URLSearchParams) before hashing, e.g. to strip cache-busting params Both options pair with the existing `matchBody`/`matchQuery` boolean toggles and run at both record and playback time so hashes stay consistent across both sides.
c1e7ba2 to
45a60e7
Compare
Member
Author
Done |
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.
Adds two new options to
SnapshotAgentandSnapshotRecorderfor partial request matching:normalizeBody(body)— normalizes the request body before hashing, e.g. to strip volatile fields like timestamps from JSON payloadsnormalizeQuery(params)— normalizes query parameters (asURLSearchParams) before hashing, e.g. to strip cache-busting paramsBoth options pair with the existing
matchBody/matchQueryboolean toggles and run at both record and playback time so hashes stay consistent across both sides.This relates to…
SnapshotAgent; #4114Rationale
When recording snapshots, sometimes we don’t want to match on the body or query params exactly; there might be volatile parts of the body or query params to exclude such as timestamps or cache-busters. In my case I want to match on the system prompt of an LLM call, ignoring the rest of the body.
Changes
Adds
normalizeBodyandnormalizeQueryoptions toSnapshotAgent, for users to define functions to simplify the recorded request body or query params before saving; and to run again when computing the hash for matching.Features
Adds
normalizeBodyandnormalizeQueryoptions toSnapshotAgent.Bug Fixes
N/A
Breaking Changes and Deprecations
N/A
Status
I tested this branch against my project and it works as intended.