Binary content
Content Retake cannot scan
Binary media types (image/*, audio/*, video/*, font/*,
application/octet-stream, application/pdf, application/zip, …), bodies that are
not valid UTF-8, and bodies compressed with an encoding Retake cannot decode are
withheld:
- Requests: the body is stored as
{"withheld":"sha256:…","bytes":48213,"media_type":"image/png"}(keybody_withheld). Inside a JSON body, base64 blocks ({"type":"base64","media_type":…,"data":…}, e.g. images and PDFs in messages) are parts of their own: an unscannable block’sdatais replaced by"withheld":"sha256:…"and"bytes", the hash and size of the decoded content. Replay withholds the incoming request the same way and matches on the hash, so a test that sends the same image still replays. Nothing but the hash, size and media type reaches the disk. - Responses: the body is withheld. Replaying that exchange answers
502with error typeretake_withheld, and the run fails (exit 1) as for an unmatched request; the replay summary counts it as withheld (with a test-runner plugin, the test that made the request fails). Replay never serves stand-in content for a withheld body. A JSON response with an unscannable base64 block is withheld whole. In a streamed response, such a block is withheld in itseventrecord (hash and size only) and the whole stream is withheld on replay; the client still gets every event as it arrives while recording. --allow-unscanned <media types>(RETAKE_ALLOW_UNSCANNED), e.g.--allow-unscanned 'image/*,application/pdf', stores matching content without scanning it, in blob files (see Blobs), in streamed events too. The take’s header lists the media ranges, and its footer lists every part stored unscanned (unscanned: exchange,request,responseorevent, JSON Pointer, media type, size, blob hash), so reviewers can see it.
Text inside base64
Base64 blocks whose media type is text-like (text/*, application/json,
application/xml, and +json / +xml types) are decoded, redacted like any other text
and stored readable, with text in place of data:
{"type": "base64", "media_type": "text/plain", "text": "deploy token: <redacted:github-token:1>\n"}
Replay re-encodes them as base64, so the client sees the wire format it was sent; on the request side they are compared decoded, so normalization rules and redaction apply to the text. A payload that does not decode as UTF-8 stays unscannable. Images and PDFs are never decoded to scan them: they stay hash-only unless opted in.
Blobs
Content stored with --allow-unscanned goes to one content-addressed directory at the
root of the takes directory, shared by every take:
tests/takes/
_blobs/
sha256-3f1c…9a2e.png
sha256-77b0…c41d.pdf
_main.take
tests/test_agent.py/test_screenshot.take
Each file holds the decoded content, named by its SHA-256 and an extension from its
media type (bin when unknown), so a reviewer can open it. The take refers to it by
hash, as a whole body (body_blob) or in place of a base64 block’s data:
{"type": "base64", "media_type": "image/png", "blob": "sha256:3f1c…9a2e", "bytes": 48213}
An image re-sent on every turn of a conversation, or by several tests, is stored once.
Blobs are written before the record that refers to them. When a take is loaded, every
blob it refers to must exist and match its hash; otherwise replay refuses the take (exit
2), naming the missing or changed blob, and retake check reports it. retake clean
removes blobs no take refers to.
Commit _blobs/ with the takes. Git diffs of binary files are not useful, so mark them
binary (retake init adds the first line below), and consider Git LFS for large ones, e.g.
in .gitattributes:
tests/takes/_blobs/** binary
# or, with Git LFS installed:
tests/takes/_blobs/** filter=lfs diff=lfs merge=lfs -text
Compressed responses
Retake asks the provider for uncompressed bodies (accept-encoding: identity). A
response compressed anyway with gzip, br or zstd, streamed or not, is decoded while
recording (a stream before its events are parsed), then classified, redacted and stored
like any other: a compressed 401 refuses the recording as an uncompressed one does.
The client receives it decoded, and replay serves it uncompressed without
content-encoding. Other encodings are passed through and withheld.
Uploads
multipart/form-data requests (e.g. the Files API) are parsed and stored part by part
under body_multipart, without the boundary, which is random on every run; the stored
content-type is multipart/form-data:
"body_multipart": [
{"name": "purpose", "text": "user_data"},
{"name": "file", "filename": "shot.png", "media_type": "image/png", "withheld": "sha256:…", "bytes": 48213}
]
Text fields (no filename, or a text-like media type) are stored as redacted text; field
names and filenames are redacted too. Other parts are binary parts: hash-only, or blobs
with --allow-unscanned. For matching, the parts compare as the JSON document
{"multipart": [...]}, so a new boundary still matches, and rules can select parts with
all or raw paths such as /multipart/0/text. The file ID an upload returns is ordinary
JSON in the response: when a session fixture uploads a file that tests refer to, those
tests depend on _session.take like any other ID (see
Session IDs and dependent takes).