Prerequisites and complete source
Complete Set up access. In a fresh project, runuv init --python 3.12 and uv add "contree-sdk[async]==0.5.1" "contree-client==0.6.0". Save as recover.py:
uv run python recover.py. You should see the intentional command failure, followed by recovered from the same known-good image.
Both attempts are disposable because they only check the saved file and print a result. ContreeAsyncSession selects a separate VM per command. Inspect result.state.exit_code, result.stdout.as_text(), result.stderr.as_text(), and each stream’s truncated flag. Use spawn() to record an operation UUID before waiting when recovery requires it. A nonzero exit is a workload result; an SDK exception can represent a platform failure, cancellation, or wait timeout. SDK 0.5.1 makes a best-effort cancellation when its wait times out. After uncertain transport or cancellation, inspect the existing operation before retrying. For files from a failed run, follow the result-image rules.
See Troubleshooting.