Dagger (in Docker) had a idea like this while and Pydantic is using external state savers like Temporal.io there are a lot of directions good luck on yours !!

Pydantic also has a first party integration with DBOS, which doesn't require an external state server.

https://ai.pydantic.dev/durable_execution/dbos/