Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Checking, listing and versions

Checking takes: retake check

retake check --takes-dir <dir> checks every take under the takes directory without running tests or calling any API, so it needs no API key. For each take it checks that:

  • every line is JSON and matches the take schema of its format, and the format and record types are ones this Retake reads;
  • the rules across lines hold and the take has a footer;
  • every blob it refers to exists in the _blobs/ of its own takes directory and matches its hash (see Blobs). That is the nearest _blobs/ between the take and the directory checked, else the checked directory’s, so a directory that holds several takes directories can be checked at once;
  • the guard passes with the current retake.toml (see The guard);
  • the redaction scan with the current patterns finds no secret, which catches hand edits and patterns added after the take was recorded. A secret found is reported by line and pattern name, never printed.

_resource.take (see retake reap) is checked too, but not counted as a take, as retake ls does not list it. It also warns about leftover .partial files, takes recorded from a run that exited non-zero or did not finish, takes from failed tests (--keep-failed), streams that never ended, and stale takes. Errors exit 1; warnings exit 0, except stale takes with --fail-on-stale. A missing takes directory or a bad retake.toml exits 2.

$ retake check --takes-dir tests/takes
tests/takes/agent/test_booking.take:3: error: schema: /status: "200" is not of type "integer"
tests/takes/agent/test_refund.take:12: error: secret: the current redaction patterns match (anthropic-api-key); remove the secret and re-record the take
tests/takes/_main.take: warning: stale: recorded by Retake 0.1.0; this is Retake 0.2.0
retake check: 14 take(s) in tests/takes checked in 41 ms: 2 error(s), 1 warning(s)

--json prints the same findings as JSON ("version": 1, described by schema/check-v1.schema.json), each with path, line (when it concerns one line), severity, kind and message. The check takes tens of milliseconds on the example takes, so it can run as a pre-commit hook, e.g. in .pre-commit-config.yaml:

repos:
  - repo: local
    hooks:
      - id: retake-check
        name: retake check
        entry: retake check --takes-dir tests/takes
        language: system
        pass_filenames: false
        files: '\.take$|^retake\.toml$'

Listing takes: retake ls

retake ls --takes-dir <dir> lists every take: its test ID (the path, for _main.take and _session.take), its age, the Retake version that recorded it (unknown for takes recorded before Retake wrote it), the models in its exchanges (requested and serving), how the recording ended (passed, failed, exit N, run unfinished or incomplete) and why it is stale. Takes that cannot be read are listed with the reason, and make retake ls exit 1 after listing everything else.

$ retake ls --takes-dir examples
TEST                                         AGE  RETAKE   MODELS            RESULT  STALE
test_refund.py::test_order_not_arrived       14h  unknown  claude-haiku-5-5  passed  -
test_refund.py::test_refund_half             14h  unknown  claude-haiku-5-5  passed  -
refund/_main.take                            23h  unknown  claude-haiku-5-5  exit 0  -

--json prints the list as JSON ("version": 1, described by schema/ls-v1.schema.json), with recorded_at, age_seconds, and outcome or run_exit as recorded in the footer.

Stale takes

A take is stale when:

  • the API version header a client sends during replay (anthropic-version) differs from the recorded one; only replay can tell, and the request still matches;
  • an older Retake recorded it: an older minor version before 1.0 (0.3 vs 0.4), an older major version from 1.0 on. Patch releases never make a take stale, and neither does age. A take without a recorded Retake version is never stale by version.

Staleness is a warning. retake replay lists every stale take at the end of the run:

retake: warning: tests/takes/_main.take is stale (anthropic-version: recorded 2023-06-01, sent 2026-10-21); re-record it

--fail-on-stale (or RETAKE_FAIL_ON_STALE=1) on retake replay and retake check makes stale takes fail the run (exit 1), for teams that want it in CI. Secrets an older Retake failed to redact are not a staleness question: retake check re-scans every take with the current patterns.

Format versions and retake upgrade

The header’s format is a single integer, raised only for changes an older Retake would misread; the Retake version and the format version are independent. Retake:

  • ignores fields it does not know, and refuses a take with a record type it does not know (exit 2), naming the type: a new record type always comes with a new format;
  • refuses a take in a newer format (exit 2), naming both versions, e.g. recorded with format 3 by Retake 0.6.0; this is Retake 0.5.2, which reads formats 1–2; upgrade Retake;
  • reads the current and the previous format, the previous one with a warning;
  • always writes the current format, so re-recording a take upgrades it.

retake upgrade --takes-dir <dir> rewrites takes in the previous format to the current one, changing their bytes but not their meaning. Format 1 is the only format so far, so today it reports that every take is already current. Before 1.0 any minor release may raise the format (with read support for the previous one and retake upgrade); from 1.0 only major releases may. retake.toml has no version key, and the --json output of retake check and retake ls carries its own "version".