BTEng — Behavior Tree Engine for Python
BTEng is a Behavior Tree engine for Python with no runtime dependencies.
pip install bteng installs one package and nothing else. Every module the engine loads
at runtime imports only the standard library, so BTEng drops into a ROS node, a PLC bridge
or an embedded controller without touching your dependency tree. Exactly two modules
import anything third-party, and neither is on that path: the ZMQ event transport
(pip install "bteng[zmq]") and the pytest plugin, loaded only by a test run that asks
for it.
Use it for robotics, automation, simulation — anything tick-driven that needs preconditions, fallbacks, retries and recovery paths rather than one large control loop.
Features
async defleaves without an async tick loop —CoroActionNodeawaits your host's coroutines; the tick loop stays synchronous.- Reactive nodes that watch the blackboard —
ReactiveSequence/ReactiveFallbackinterrupt a running action the moment a guard stops holding. - Introspection built in — Inspector, structured logger, execution tracer with replay and an optional ZMQ stream, all fed from one point.
- Full node library —
Sequence,Fallback,Parallel,Inverter,RetryUntilSuccessful,Timeout,RateController,ForceSuccess/ForceFailure. - Long-running work —
StatefulActionNode, andAsyncActionNodewith aCancellationTokenand an auto-injectedThreadPool. - Two ways to build trees — the fluent
TreeBuilder, or BehaviorTree.CPP v4-style XML with subtrees and preconditions (_skipIf,_while, …). - Scoped, observable blackboard — change subscriptions, provenance history, schema validation.
- Extensible and testable —
@register_node, plugin loading, mock nodes,BehaviorTreeTest, and abteng runCLI.
Install
pip install bteng
Requires Python 3.12 or newer.
Quick Start
from bteng import Blackboard, NodeStatus, TreeBuilder, TreeExecutor
bb = Blackboard.create("demo")
bb.set("battery_level", 87)
tree = (
TreeBuilder(blackboard=bb)
.tree_id("Mission")
.sequence("root")
.condition("BatteryOK", lambda: bb.get("battery_level", 0) > 20)
.action("Navigate", lambda: NodeStatus.SUCCESS)
.end()
.build()
)
executor = TreeExecutor()
executor.set_tree(tree)
print(executor.tick_until_result(max_ticks=100)) # NodeStatus.SUCCESS
Trees can also live in XML, so behavior is data you edit without touching code
(Timeout is in milliseconds):
<root BTEng_format="1.0" main_tree_to_execute="main">
<BehaviorTree ID="main">
<ReactiveFallback name="root">
<ReactiveSequence name="navigate_if_safe">
<Condition ID="PathClear"/>
<Timeout duration="10000">
<RetryUntilSuccessful num_attempts="3">
<Action ID="NavigateTo" goal="{target_goal}"/>
</RetryUntilSuccessful>
</Timeout>
</ReactiveSequence>
<Action ID="StopRobot"/>
</ReactiveFallback>
</BehaviorTree>
</root>
Documentation
| Page | What it is |
|---|---|
| Documentation index | Every page, grouped by level |
| Quick Start | Your first tree in five minutes |
| Which API should I use? | Python, XML, legacy BehaviorTreeEngine, advanced APIs |
| Core Concepts | Statuses, control nodes, decorators, blackboard, ports, tick loop |
| Beginner guide | Control nodes, actions, blackboard, TreeBuilder, first tests |
| Recipes | Guards, retry with recovery, async actions, subtree reuse |
| Advanced guide | Ports, reactive internals, plugins, introspection, ZMQ, runtime modification |
| XML reference | The full XML format, port syntax, preconditions, loading from Python |
| Node reference | Node lifecycle, port model, custom node authoring |
| Command line | bteng run and bteng licenses |
| Examples | Two runnable programs with XML trees, no hardware needed |
| Architecture | Component relationships and data flow |
| Changelog | Release history |
| Licensing | Third-party audit and open-source alternatives |
Acknowledgements
BTEng's design is inspired by BehaviorTree.CPP, a widely used C++ behavior tree library.
License
BTEng is released under the MIT License. See LICENSE for terms.
Metadata
Release files for bteng 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bteng-0.4.0.tar.gz | 185.7 kB | Without provenance | Details for bteng-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bteng-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for bteng-0.4.0-py3-none-any.whl |
Total release size: 319.9 kB
Release files / bteng-0.4.0.tar.gz
| Download URL | bteng-0.4.0.tar.gz |
|---|---|
| Size | 185.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2de6cea785d7cad0e1c6e03b51b07dc175a735d05184adf2c038ee4c6964c0ce
|
|
BLAKE2b-256 checksum How to use checksums |
10fa1f85d6f972fceeee2947fbec9a25a18af928836367fe7a02773c098db42b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / bteng-0.4.0-py3-none-any.whl
| Download URL | bteng-0.4.0-py3-none-any.whl |
|---|---|
| Size | 134.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
437e5c7ff176560ebac6d30f331731aae121a41cdddd0eca88645ee92c85087b
|
|
BLAKE2b-256 checksum How to use checksums |
cf6aa4a0310baf0e2d6b205b7226a01bbd8c0ab87fb4b2de488545b343262313
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for bteng 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.