> ## Documentation Index
> Fetch the complete documentation index at: https://skyvern.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Code Caching

> Skyvern records the actions an AI run takes and generates executable code from them. Subsequent runs execute the cached code directly, skipping LLM inference and screenshot analysis. Faster, cheaper, deterministic.

When Skyvern's agent completes a task or agent run, it records the actions it took and generates reusable code from them. Later runs can execute that cached code directly, skipping LLM inference and screenshot analysis entirely. This makes cached runs faster, cheaper, and deterministic. If the cached code fails because a page changed, Skyvern falls back to the agent automatically and regenerates the cache.

## How it works

The first run uses the agent as normal. Create an agent and run it with `run_with="agent"` so Skyvern can record the successful browser actions as generated code.

On subsequent runs, pass `run_with="code"` to execute the cached code directly. No screenshots, no LLM reasoning, just the recorded action sequence replaying against the page.

If the cached code hits something unexpected (a layout change, a new field, a missing element), Skyvern re-runs with the full agent and regenerates the cache. You don't need to handle this yourself.

<Note>
  The SDK and Cloud UI default to `skyvern-1.0` for new task creation. Use agents plus `run_with="code"` for cached replays.
</Note>

## What gets cached

**Tasks** cache the full action sequence the agent took: clicks, form fills, extractions, and navigation.

**Agents** cache per block. Each block that successfully executes gets its own cached script, so a partially-cached agent still saves time on the blocks that have been seen before.

**Progressive caching** handles agents with conditionals. Run 1 covers branch A, run 2 covers branch B, and so on. Previous caches are preserved, so coverage builds up over time.

**Not cached:** conditional evaluation blocks, wait blocks, and code blocks always run live because their behavior depends on runtime state.

<Tip>
  Pair cached code with [scheduled agents](/cloud/building-agents/scheduling) for cheap, reliable recurring runs. The first scheduled run builds the cache, and every subsequent run executes from it.
</Tip>

## Learn more

<CardGroup cols={2}>
  <Card title="Cost control" href="/developers/optimization/cost-control">
    Use `run_with: code` plus `max_steps` and engine tiers to manage costs.
  </Card>

  <Card title="Scheduling agents" href="/cloud/building-agents/scheduling">
    Run cached agents on a cron schedule.
  </Card>

  <Card title="Reliability tips" href="/developers/going-to-production/reliability-tips">
    Keep cached runs stable as target sites evolve.
  </Card>

  <Card title="Run from code" href="/cloud/building-agents/run-from-code">
    Trigger and monitor cached agents from your own code.
  </Card>
</CardGroup>
