Nodes in go-bt return state instantly: 1 for Success, 0 for Running, -1 for Failure. Then they yield. No blocking calls, no infinite loops. A supervisor decides what runs next.
The design is tight. Nodes hold no state themselves. All temporal memory lives in a generic BTContext[T] that embeds Go's context.Context, so cancellations propagate through the tree automatically. But the real draw is clock injection. You can verify a five-minute timeout instantly by mocking the clock. No waiting, no flaky CI failures.
This matters for production async code where timing tests are a constant headache. For those building complex AI agent services, go-bt provides practical patterns for state management and testing.
Behavior Trees spent years in game AI before drifting into backend systems. They handle retry logic, fallback strategies, circuit breaking. The same territory Netflix Hystrix and Resilience4j cover. But instead of state machines, you compose behaviors declaratively. Wrap an action in a Retry decorator. Put fallbacks in a Selector. The tree makes execution paths visible.
Hacker News commenters saw potential for microservice orchestration and liked the testing approach. The library is young though. Parallel composite nodes aren't there yet, and some find behavior trees harder to reason about than data-driven state machines. Still, author rvitorper built something practical here. For Go developers building async services, the first-class testing support alone makes go-bt worth a look.