resource() returns a handle
that the SDK checkpoints during execution and restores in a fork.
This example uses LangChain and the E2B
driver below:
agent.py
Declaring what a step changes
resources on @tool, wrap_tool, and step() identifies what the call may change:
- Default: none.
["workspace"]: the named resource.
Checkpoint policy
Each resource has its own policy, preserved across dispatches and forks:
Failed calls and calls cancelled after starting count. Replay, denied calls,
and LLM calls do not. A due capture runs after the body and before its outcome
returns. Capture failure leaves that outcome intact and the resource uncovered.
Writing a driver
Pass an object with these members:
The kernel stores the JSON binding and checkpoint references; the provider
stores the captured contents. Keep
driver_id and configuration stable for
each resource key.
Fork coverage
A fork point is covered when every registered resource has matching captured state. Every event can be forked. An uncovered fork uses the newest earlier checkpoint, or the initial environment if none exists; copied results still replay and may describe changes absent from the restored state. By default, coverage ends at the next live step. A driver can setcoverage_reuse = True to keep it until an affecting tool or local step starts.
Use this when all changes happen through declared tools and steps.
A driver raises CheckpointUnavailable
if the selected checkpoint is expired or missing, failing the forked execution.
See Forks for the kernel flow.