Behavior Tree Back-Chaining Construction
Build a behavior tree where every node exists only because it helps meet its parent's needs, so there are no dead branches and no hand-bolted structure.
Description
Build an agentic behavior tree by working backwards from the goal. Start at the goal. Add an action whose result meets the goal. That action has its own needs, so add actions that meet those needs. Keep going until every leaf is something you can run directly. Behavior trees give you tidy, modular control flow. Working backwards (back-chaining) means every node is there for a reason, not bolted on by hand. Leaves mix LLM calls and tool calls. The tree itself becomes the record of how the agent's behaviour was put together.
When to apply
Use this when you need structured agent control flow that mixes LLM nodes and tool nodes: game-like worlds, multi-step task agents, or involved workflows. It helps most when a prompt-only agent has turned into spaghetti. Don't apply it for a simple straight-line pipeline or a single-shot prompt, where a tree is just overhead. Skip it too when the task is truly open-ended exploration that you cannot break into goals.
What it involves
- State the goal as a root precondition
- Find actions whose post-conditions satisfy the parent
- Recurse on each child's preconditions
- Choose composite node types
- Wire leaves to LLM calls and tool invocations
- Validate the tree end-to-end
Open the full interactive page →
Diagram, neighbourhood map, code examples, related patterns and full provenance.