Nicholas Pini
02/19/2026, 3:57 PMMarvin
02/19/2026, 3:57 PMMarvin
02/19/2026, 4:02 PMPREFECT_RESULTS_PERSIST_BY_DEFAULT=true, and
- PREFECT_DEFAULT_RESULT_STORAGE_BLOCK=s3-bucket/my-s3-block (or the canonical PREFECT_RESULTS_DEFAULT_STORAGE_BLOCK=s3-bucket/my-s3-block)
will cause flow and task results to be persisted by default to that S3 block, unless you explicitly override persistence on a given flow/task.
Details and gotchas:
- Either env var name for the storage block works: PREFECT_RESULTS_DEFAULT_STORAGE_BLOCK (recommended) or PREFECT_DEFAULT_RESULT_STORAGE_BLOCK (also supported).
- Precedence rules:
- Task/flow-level persist_result or result_storage parameters override the env vars.
- If a task has @task(persist_result=False), it will not persist even with the env vars set.
- The S3 block must exist in your workspace and be loadable from the run environment.
- Make sure the runtime has:
- The Prefect AWS collection installed (prefect-aws) so the S3 block can write to S3.
- IAM permissions to write to the target bucket (e.g., via the CodeBuild role or AWS_* env vars).
- Optional (not required): If you want non-pickle serialization, set PREFECT_RESULTS_DEFAULT_SERIALIZER=json.
No other Prefect env vars are strictly required for default result persistence to S3 beyond the two you listed.Nicholas Pini
02/19/2026, 4:03 PMPREFECT_TASKS_DEFAULT_PERSIST_RESULT do? What is the difference?Marvin
02/19/2026, 4:03 PMMarvin
02/19/2026, 4:05 PMpersist_result set.
- It takes precedence over both the flow’s persist_result and PREFECT_RESULTS_PERSIST_BY_DEFAULT.
Precedence for a task’s persistence (highest to lowest):
1) Task-level persist_result on the decorator
2) PREFECT_TASKS_DEFAULT_PERSIST_RESULT
3) Flow-level persist_result
4) PREFECT_RESULTS_PERSIST_BY_DEFAULT
5) Default: False (no persistence)
Concrete examples:
- If you set PREFECT_TASKS_DEFAULT_PERSIST_RESULT=false and your flow has @flow(persist_result=True), tasks will NOT persist (the task default overrides the flow).
- If you set PREFECT_RESULTS_PERSIST_BY_DEFAULT=true but do not set PREFECT_TASKS_DEFAULT_PERSIST_RESULT, tasks will persist unless the flow/task says otherwise.
- If a task has @task(persist_result=True), it will persist regardless of either env var.
Env var name:
- The correct env var is PREFECT_TASKS_DEFAULT_PERSIST_RESULT (no aliases).