from __future__ import annotations from copy import deepcopy from typing import Any def with_raw_payload(record: dict[str, Any]) -> dict[str, Any]: payload = {key: deepcopy(value) for key, value in record.items() if key != "raw_payload"} return {**record, "raw_payload": payload}