Reuse task results
Cache JSON outputs when a task can safely reuse a result for the same inputs.
Cache a task
Section titled “Cache a task”Add a cache policy when a task can reuse the same JSON result for the same inputs. Give the policy a store, a version and a key that identifies the inputs affecting the result.
The second run restores the first result: execution stays at 1 and cacheHit is true.
Choose the key
Section titled “Choose the key”The fingerprint combines the workflow name, the task key, version and the JSON value key(ctx) returns. Put in it everything that can change the answer.
API reference: TaskCacheOptions and TaskCacheEntry.
repositoryFingerprint() hashes HEAD, the index, uncommitted changes and non-ignored untracked files outside .outpost/, so a local edit changes the key. A key that throws or is not lossless JSON fails the task.
Understand a cache hit
Section titled “Understand a cache hit”| On a hit | Result |
|---|---|
| Task value | Restored and passed to dependent tasks |
TaskRecord.cacheHit | true |
| Attempts, usage, attempt budget | None recorded or consumed |
| Files, commits, branches, sandbox state, artifacts, calls | Not replayed |
Cache tasks whose value is the product: reviews, classifications, summaries, analyses.
Pick a task that accepts a cache
Section titled “Pick a task that accepts a cache”The result must be lossless JSON or undefined; otherwise the task fails after it executes, without a retry.
API reference: TaskCacheOptions, TaskOptions and QueuedTaskOptions.
Expire or refresh entries
Section titled “Expire or refresh entries”API reference: TaskCacheOptions.
Watch cache events
Section titled “Watch cache events”Log cache outcomes from the workflow observer to see hits, misses and storage errors. A cache failure does not prevent the task from running or completing.
API reference: TaskCacheOutcome.
The cache never decides the outcome: after a failed read the task runs, after a failed write it completes normally.
Protect and prune entries
Section titled “Protect and prune entries”Entries live under task-cache/ in the transport until you remove them. Add the task-cache scope to a retention policy to prune those older than minAgeMs.
Limits
Section titled “Limits”- Concurrent executions with the same fingerprint all run; the first entry written is kept.
- A task already completed in a checkpoint is restored from it without reading the cache.
- Entries are not invalidated when your code or agent changes: change
version. createTaskCacheStoredoes not store entries above 16 MiB (maxBytes); the write reportsfailed.- Do not cache a
defineArtifactTaskread by a later task: a hit in a new run restores a reference to the earlier run, andreadArtifact()fails with “Artifact dependency producer mismatch”.
API: TaskCacheOptions · createTaskCacheStore · repositoryFingerprint · TaskCacheEntry · WorkflowEvent.