def new_checkpoint_callback_for_run(self) -> CheckpointCallback:
        """Closure to generate a new `CheckpointCallback` with a unique run-id."""

        async def _create_checkpoint(
            run_id: str,
            last_completed_step: Optional[str],
            input_ev: Optional[Event],
            output_ev: Optional[Event],
            ctx: "Context",
        ) -> None:
            """Build a checkpoint around the last completed step."""
            if last_completed_step not in self.enabled_checkpoints:
                return

            checkpoint = Checkpoint(
                last_completed_step=last_completed_step,
                input_event=input_ev,
                output_event=output_ev,
                ctx_state=ctx.to_dict(serializer=self._checkpoint_serializer),
            )
            async with self._lock:
                if run_id in self.checkpoints:
                    self.checkpoints[run_id].append(checkpoint)
                else:
                    self.checkpoints[run_id] = [checkpoint]

        return _create_checkpoint
Closure to generate a new `CheckpointCallback` with a unique run-id.
llama-index-core/llama_index/core/workflow/checkpointer.py