Self-Crystallizing Behavior Trees: Amortizing Foundation-Model Reasoning into Deterministic Control for Autonomous Drones
Organizations: Software Department, KavAI. California, USA
Abstract
Classical robot control, Finite State Machines and Behavior Trees (BTs), is deterministic and inspectable but fixed at design time: it fails on situations its designers did not anticipate. Foundation models can synthesize new control logic at runtime, at a cost in latency and non-determinism hard to accept in safety-critical aerial systems. Existing LLM-driven approaches keep the model in the loop permanently and discard what it produces. We propose Self-Crystallizing Behavior Trees (SCBT), in which the foundation model is a compiler rather than a runtime. When a BT node fails, an LLM proposes a minimal, mission-agnostic subtree patch; CMA-ES tunes its parameters in simulation; a contextual bandit decides whether a stored patch or a new LLM call is worth its cost; and a three-stage admission pipeline (static check, invariant-monitored replays, an empirical margin over the unpatched tree) admits only patches that demonstrably recover. Admitted patches are stored in a fleet library and, once the LLM call rate decays, crystallized into a deterministic BT that no human wrote. We implement SCBT on Microsoft Project AirSim with a schema-constrained LLM pipeline (Gemini 3.1 Pro) and a lockstep simulator. Over three seeds of a 20-episode learning phase with wind-gust and battery failures, SCBT used LLM calls against 26 for whole-tree regeneration and 22 without a library, with 0.33 calls per episode in the second half. The crystallized trees, 28 and 33 nodes with two patches each, reached mission success with no learning running, against 12% for the unpatched tree and 98% for a hand-coded expert tree, and reproduce decision traces exactly when re-ticked offline. Two negative results: replay admission rejected useful wind recoveries by attributing wind-induced geofence excursions to the patch, and a static-only ablation generalized better to held-out failures.
Figures & tables
| Method | Seeds | Success | Value | LLM calls | Calls/ep. 11–20 | Adm./rej. | Hits | Replays |
|---|---|---|---|---|---|---|---|---|
| B1 regenerate whole tree | 1 | 0.55 | 0.50 | 26 | 1.20 | 11 / 11 | 0 | 308 |
| B2 no library | 1 | 0.40 | 0.33 | 22 | 1.00 | 9 / 11 | 0 | 342 |
| B3 no CMA-ES tuning | 1 | 0.65 | 0.57 | 12 | 0.10 | 3 / 9 | 10 | 120 |
| B4 no bandit (nearest nb.) | 1 | 0.80 | 0.65 | 18 | 0.70 | 4 / 10 | 25 | 252 |
| B5 static admission only | 1 | 0.85 | 0.70 | 10 | 0.40 | 10 / 0 | 22 | 0 |
| B6 no cross-class transfer | 1 | 0.65 | 0.55 | 13 | 0.40 | 2 / 9 | 13 | 188 |
| Curriculum | Held-out | End-to-end | Offline | Nodes | ||||
| Method | Succ. | Value | Succ. | Value | Distinct | Spread | Dist./faithful | M1 / M2 |
| Base (unpatched) | 0.00 | 0.00 | – | – | – | 15 / 20 (0) | ||
| B0 expert | 1 / 10 | 0 | 1/3, 30/30 | – | ||||
| B2 no library | 1.00 | 0.85 | 0.40 | 0.30 | 1 / 10 | 0 | 1/3, 10/10 | 77 / 82 (9+9) |
| B3 no CMA-ES tuning | 1.00 | 0.85 | 0.45 | 0.35 | 4 / 10 | 33 | 1/3, 10/10 | 33 / 38 (3+3) |
| B4 no bandit | 0.80 | 0.62 | 0.15 | 0.10 | 1 / 10 | 0 | 1/3, 10/10 | 37 / 42 (4+4) |
Behavior Trees
Behavior trees are hierarchical, reactive control structures for organizing tasks, actions, and recovery in robots and autonomous agents.
See all 19 papers