# _record

URL: /milo-cli/api/milo/testing/_record/
Section: testing
Description: Session recording — action log writer.

---

> For a complete page index, fetch /milo-cli/llms.txt.

Open LLM text
(/milo-cli/api/milo/testing/_record/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Ftesting%2F_record%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Ftesting%2F_record%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Ftesting%2F_record%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2Ftesting%2F_record%2Findex.txt)

Module

#
`testing._record`

Session recording — action log writer.

2Classes4Functions

## Classes

`ActionRecord`

3

▼

Single recorded action with timestamp.

Single recorded action with timestamp.

#### Attributes

Name
Type
Description

`timestamp`

`float`

—

`action`

`Action`

—

`state_hash`

`str`

—

`SessionRecording`

4

▼

Complete recorded session.

Complete recorded session.

#### Attributes

Name
Type
Description

`initial_state`

`Any`

—

`records`

`tuple[ActionRecord, ...]`

—

`final_state`

`Any`

—

`metadata`

`dict[str, str]`

—

## Functions

`state_hash`

1

`str`

▼

SHA256 hash of state repr, truncated to 16 chars.

`def state_hash(state: Any) -> str`

##### Parameters

Name
Type
Description

`state`
`Any`

##### Returns

`str`

`recording_middleware`

1

`Any`

▼

Create a middleware that records actions and state hashes.

`def recording_middleware(records: list[dict]) -> Any`

##### Parameters

Name
Type
Description

`records`
`list[dict]`

##### Returns

`Any`

`save_recording`

5

`None`

▼

Save a session recording to JSONL.

`def save_recording(path: str | Path, initial_state: Any, records: list[dict], final_state: Any, metadata: dict[str, str] | None = None) -> None`

##### Parameters

Name
Type
Description

`path`
`str | Path`

`initial_state`
`Any`

`records`
`list[dict]`

`final_state`
`Any`

`metadata`
`dict[str, str] | None`

Default:`None`

`load_recording`

1

`SessionRecording`

▼

Load a session recording from JSONL.

`def load_recording(path: str | Path) -> SessionRecording`

##### Parameters

Name
Type
Description

`path`
`str | Path`

##### Returns

`SessionRecording`
