Skip to main content
Use a semaphore or fixed worker pool. Give each work item a stable application ID and record: Tags can move while a batch runs; resolve them before scheduling. Plan for no more than 50 simultaneous operations, then keep the application bound below the effective limit returned for the current token. Leave room for recovery or interactive work.

Give each independent workload its own session

For SDK 0.5.1, create a ContreeAsyncSession per independent item and bound the number of active items with asyncio.Semaphore. Each session starts from the same immutable image UUID. A shared default lazy session would run commands inside one VM, so it is unsuitable when items require separate environments. Inside the semaphore, enter create_sandbox_session(image=image_uuid, session_type=ContreeAsyncSession), await session.run(...), and inspect result.state.exit_code and decoded output. Use disposable=True when the batch only needs process results. The evaluation recipe provides a complete program. Use await session.spawn(...) when operation IDs must be recorded before waiting. Keep the returned handle, await operation.wait(), and close it with await operation.shutdown(). For retained results, call await session.commit_result(operation) after a successful wait. Concurrent retained operations from the same history position form sibling entries; their files are not merged automatically.

Classify before retrying

Create requests have no documented idempotency key. An application item ID helps reconcile duplicates but does not make execution idempotent.

Stop safely

On an early-stop condition, stop scheduling, cancel unfinished operation IDs owned by this batch with DELETE /v1/operations/{operation_id}, and observe each terminal state until a deadline. Never use a project-wide cancel-all action from shared automation. Resume cancelled work from its recorded input image UUID. Follow the result-image rules when recovering files from cancelled work. Contact the Sandboxes team if cancellation retention or usage affects capacity or cost controls. See Run a bounded evaluation batch, Troubleshooting, and Limits, retention, and usage.