← Back to glossary

Coroutine

A unit of execution that can suspend its own work at a waiting point and resume later while preserving state. With async and await, a coroutine returns control to the event loop while waiting for network, disk, or another operation, allowing the process to advance independent tasks without dedicating one thread to every wait.

Concurrency does not imply parallelism. In agent systems, coroutines help coordinate tool and model calls, but they require predictable timeouts, cancellation, backpressure, and cleanup. An abandoned task or a non-idempotent resume can leave resources open or repeat external effects.