Skip to main content
AsyncCapsule is the async counterpart to Capsule. Every method that performs I/O — running commands, reading and writing files, pausing and resuming, opening a PTY — has an async equivalent that you await. The interface is identical to the sync API; the only difference is the await keyword and the async with context manager.

Creating an async capsule

Use await AsyncCapsule.create(...) to create a capsule, then use it as an async context manager. The capsule is destroyed automatically when the block exits.

Commands and files

All command and file operations are awaitable:

Lifecycle operations

pause and resume are awaitable just like the sync versions:

Async code interpreter

Import AsyncCapsule from wrenn.code_interpreter for stateful async code execution:

Async PTY

Use capsule.pty() as an async context manager and iterate over events with async for:
AsyncCapsule mirrors the sync Capsule API exactly — every method has the same name and accepts the same parameters. The only change is adding await and using async with / async for where appropriate.