TECHNOLOGY

Prefect cache identity can include the flow run

In this article
THE QUICK TAKE

Define what makes an agent task result reusable before changing the cache key; matching function inputs may omit dependencies that changed outside the task.

Follow a repeated classification through its key

A task classifies the same document twice during a flow and later processes it in another flow run. Prefect’s current cache-policy source defines DEFAULT as a combination of inputs, task source and run identity. Including run identity makes reuse different from a global function-input memoization rule. Inspect the effective task policy before explaining why apparently identical calls did or did not reuse a result.

Distinguish explicit cross-run reuse

An explicitly chosen policy can combine input and source identity without including the current run. That broadens the reuse scope. Decide whether the task is a stable transformation or a request for a fresh observation. For model classification, the same document identifier can point to changed text, and the same model label can route differently. Include the versioned facts the task actually depends on, or choose a refresh approach consistent with the user’s requested freshness.

Account for dependencies outside task source

The source-policy implementation considers the task’s raw source, rather than recursively hashing nested tasks and every imported helper. A helper change or external configuration change can therefore matter without appearing in that component of the key. Progressive reading helps identify the actual dependency chain. Do not describe source-based caching as proof that the entire software environment and every external dataset remained equivalent.

Separate key identity from stored availability

The task reference exposes cache policy, expiration, refresh and result-persistence controls. The transaction implementation looks for a stored record by key. Computing the same key does not independently prove an accessible reusable result exists. Storage configuration and lifecycle remain relevant, especially when several workers or environments are intended to share records.

Make the reuse decision visible in the output

Attach the source revision and relevant generation configuration to the task’s recorded result when those facts explain its meaning. A cached classification should be distinguishable from a newly requested observation if the consumer cares about freshness. Tool observations separate key matching, cache use and actual execution. The goal is an explainable reuse contract: the application knows why the old result is still suitable, rather than merely observing that a cache lookup succeeded.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles