About this project

Bonsai is a Rust library for building Behavior Trees (BTs), a data structure used to define how behaviors execute and in what order. It targets deterministic AI applications such as robotics and game programming, where modular and reactive control flow is important. The crate is published as bonsai-bt on crates.io and also offers Python bindings via PyPI under the same name. The library provides a range of control nodes: Sequence, Select, If, Invert, AlwaysSucceed, Timeout, While, WhileAll, WhenAll, WhenAny, Race, and After. Nodes signal Success, Failure, or Running, allowing parent nodes to decide the next process. For long-running tasks, Bonsai supports dispatching async or sync jobs to background threads and receiving status through channels, keeping tree traversal responsive. Documentation includes concept guides, examples, and a development guide. The project has CI builds, code coverage reporting, and is maintained under the MIT license. Example use cases and additional details are available in the examples folder and docs directory.