Hybrid Behavior Trees

A production-grade behavior tree engine combining deterministic control flow with LLM-powered adaptive reasoning for intelligent autonomous systems.


What is Igris BTree?

Igris BTree is a hybrid behavior tree system that bridges the gap between traditional deterministic behavior trees and modern LLM-powered adaptive intelligence. It provides a robust framework for building complex autonomous behaviors that can both follow predefined plans and dynamically adapt to unexpected situations.

Core Philosophy

The system is built on three fundamental principles:

  1. Deterministic + Adaptive: Combine reliable control flow with intelligent adaptation
  2. BYOM (Bring Your Own Model): No vendor lock-in, use any LLM provider you choose
  3. Real-Time Safe: Bounded execution with hard deadlines and safety mechanisms

Key Features

Deterministic Control Flow

Traditional behavior tree nodes for reliable, predictable execution:

  • Sequence: Execute children in order (AND logic)
  • Selector: Try children until success (OR logic / fallback)
  • Parallel: Execute children concurrently
  • Decorators: Retry, Timeout, Inverter, Repeat

LLM-Powered Adaptive Reasoning

Dynamic planning and recovery capabilities:

  • LLMPlannerNode: Generate behavior subtrees on-the-fly
  • SubtreeLoader: Execute dynamically generated plans
  • ReplanOnFailure: Automatic recovery via LLM when actions fail

Production-Ready Runtime

  • BTreeExecutor: Lifecycle management with tick loop automation
  • Bounded Execution: Max ticks, deadlines, and cancellation support
  • Watchdog Safety: Prevents infinite loops and runaway execution
  • Real-Time Guarantees: Integration with igris-rt for LLM timeout enforcement

Visualization & Monitoring

  • TreeVisualizer: Real-time tree state export
  • Execution Tracing: Tick-by-tick history
  • Metrics Collection: Replan count, tick rate, failure rates, LLM latency
  • JSON Export: Dashboard-ready format for WebSocket/REST integration

BYOM Architecture

  • Pluggable LlmProvider trait: Bring your own model
  • No vendor lock-in: Works with local models, cloud APIs, or mocks
  • Full control: Choose your inference backend, costs, and privacy policy

Architecture Overview

┌─────────────────────────────────────────────────────┐
│  Deterministic BTree Control Layer                  │
│  ├─ Sequence: Execute children in order            │
│  ├─ Selector: Try until success (fallback)         │
│  └─ Parallel: Execute children concurrently        │
└─────────────────────────────────────────────────────┘
         ▲                            ▲
         │ Hybrid Integration         │
┌────────┴────────────────────────────┴───────────────┐
│  LLM-Powered Adaptive Nodes                         │
│  ├─ LLMPlannerNode: Generate dynamic subtrees      │
│  ├─ SubtreeLoader: Load LLM plans at runtime       │
│  └─ ReplanOnFailure: Auto-recovery via LLM         │
└─────────────────────────────────────────────────────┘
         ▲
         │ Pluggable (BYOM)
┌────────┴─────────────────────────────────────────┐
│  LlmProvider Trait (customer-supplied)           │
│  - Local models (Phi-3, Qwen, etc.)              │
│  - Cloud APIs (if customer chooses)              │
│  - Mock provider (testing)                       │
└──────────────────────────────────────────────────┘

Use Cases

Robotics & Autonomous Systems

  • Warehouse Robots: Navigate, pick items, handle obstacles
  • Delivery Drones: Plan routes, adapt to weather, recover from failures
  • Agricultural Robots: Follow crop rows, adapt to terrain variations
  • Service Robots: Interact with humans, adapt to dynamic environments

Mission Planning

  • Multi-Phase Operations: Deterministic sequences with adaptive recovery
  • Reconnaissance: Explore unknown environments with dynamic replanning
  • Search & Rescue: Adapt strategies based on discovered conditions

Game AI

  • NPC Behaviors: Predictable patterns with adaptive responses
  • Boss Encounters: Scripted phases with dynamic tactics
  • Companion AI: Follow player with intelligent problem-solving

Process Automation

  • Workflow Automation: Structured processes with exception handling
  • DevOps Pipelines: Build, test, deploy with intelligent recovery
  • Data Processing: ETL workflows with adaptive error handling

Why Hybrid Behavior Trees?

The Problem with Pure Deterministic Trees

Traditional behavior trees are:

  • ✅ Predictable and testable
  • ✅ Easy to debug and visualize
  • ❌ Brittle when facing unexpected situations
  • ❌ Require exhaustive pre-planning for edge cases
  • ❌ Cannot adapt to truly novel situations

The Problem with Pure LLM Agents

Pure LLM-based systems are:

  • ✅ Flexible and adaptive
  • ✅ Can handle novel situations
  • ❌ Unpredictable and hard to test
  • ❌ Expensive (many LLM calls)
  • ❌ Difficult to debug and validate
  • ❌ May violate safety constraints

The Hybrid Solution

Igris BTree combines the best of both worlds:

  • Predictable core behaviors (deterministic nodes)
  • Adaptive recovery (LLM-powered replanning)
  • Testable with mocks (MockLlmProvider for unit tests)
  • Cost-efficient (LLM only when needed)
  • Safe execution (bounded timeouts, watchdog)
  • Debuggable (visualization, tracing, metrics)

Example: A warehouse robot follows a deterministic navigation sequence. When it encounters an unexpected obstacle, the ReplanOnFailure decorator triggers an LLM to generate a recovery plan. Once recovered, it returns to the deterministic sequence.


Performance Characteristics

Execution Speed

  • Deterministic nodes: Sub-millisecond tick times
  • LLM nodes: Bounded by LLM inference (typically 100ms-5s)
  • Visualization export: <5ms overhead per tick
  • Overall impact: Negligible for most applications

Memory Usage

  • Tree structure: ~100 bytes per node
  • Blackboard: Depends on stored data (typically <1MB)
  • Visualization trace: ~20KB with default settings
  • Total overhead: <1MB for typical trees

Scalability

  • Tree size: Tested with 100+ nodes
  • Tick rate: Up to 1000 ticks/second for simple trees
  • Concurrent trees: Limited only by system resources
  • Fleet deployment: Works with igris-fleet for multi-agent coordination

Getting Started

Ready to build your first hybrid behavior tree?

  1. Quick Start - Build your first tree in 10 minutes
  2. Core Concepts - Understand the fundamentals
  3. Node Types - Learn about all available nodes
  4. LLM Integration - Add adaptive intelligence

Production Readiness

Igris BTree is production-ready with:

  • 67 comprehensive tests (47 unit + 17 integration)
  • Full API documentation (rustdoc)
  • Safety mechanisms (Watchdog, timeouts, bounds)
  • Visualization tools (Real-time monitoring)
  • Battle-tested (Used in real robotics applications)

System Status: Stable, actively maintained, ready for deployment.


Community & Support


Next Steps

Quick Start

Build your first hybrid behavior tree

Get Started →

Core Concepts

Learn the fundamentals of behavior trees

Learn More →

API Reference

Complete API documentation

View Docs →

Examples

Working code examples and patterns

See Examples →