An agent books a table and a taxi, and then tells your friend Maria that dinner is on. Then the restaurant refuses the booking. You can cancel the taxi, perhaps for a fee. You cannot cancel the message.
In a database you would roll back. Here there is nothing to roll back: the restaurant made the reservation in its own system, and the message has left. The best an agent can do afterwards is ask for a new action that offsets the old one. This article is about the cheaper move, which is to order the plan so that the step nobody can take back runs only after the steps that might still fail. It shows how Robotelos does that with plain data and a sequence, without asking the model to remember the rule.
Undo is a new action
The idea of compensation is old. In 1987 Hector Garcia-Molina and Kenneth Salem proposed writing a long-lived transaction as a saga: smaller steps, each paired with a compensating step that undoes it from a semantic point of view. The word that matters is semantic. A compensation does not restore the world. It produces a new state that the parties accept as close enough, and it can fail, cost money or be impossible.
A cancellation is therefore an action in its own right. It needs its own permission, because a fee you have not seen is a decision you have not made. It needs its own key, because it can end unknown like any booking. And it needs evidence that it worked. The most useful single lesson from the saga idea is to need compensation less.
How Robotelos orders the work
A plan in Robotelos is data that code validates. Each step names a capability, its input, the steps it depends on, and the facts it produces. This is a trimmed example:
{
"goal": {
"statement": "A table for two at seven, then a taxi to it",
"criteria": [
{ "key": "table_booked", "fact": "table.status", "op": "equals", "value": "confirmed" },
{ "key": "taxi_booked", "fact": "taxi.status", "op": "equals", "value": "confirmed" }
]
},
"steps": [
{ "key": "book_table", "capability": "restaurant.reserve", "input": { "...": "..." },
"dependsOn": [], "produces": { "table.status": "status" } },
{ "key": "book_taxi", "capability": "taxi.book", "input": { "...": "..." },
"dependsOn": ["book_table"], "produces": { "taxi.status": "status" } }
]
}
Three mechanisms make the order real instead of advisory.
Steps are sorted by dependency and run as a sequence. The compiler orders steps topologically and rejects cycles and unknown dependencies. The Behavior Tree is a sequence of one region per step, and a sequence starts the next child only after the previous one has succeeded. It remembers its position from the operation outcomes alone, so after a crash it needs no memory of its own:
case Sequence:
for _, c := range n.Children {
d, err := eval(t, c, outcomes, path)
if d.Status != Success {
return d, nil // running, or failed: later children do not start
}
}
return Decision{Status: Success}, nil
Success means the promised outcome, not a reply. A step counts as succeeded when its operation is SUCCEEDED, and a capability declares what that means. For restaurant.reserve, the result must have status equal to "confirmed". A well-formed but unconfirmed reply does not release the next step, and a lost reply leaves the operation UNKNOWN, which holds everything behind it.
The goal reads facts, not the model’s words. Goal criteria are evaluated against recorded facts with three values: true, false and unknown. Unknown never becomes false, and a fact that has not been observed is not a fact that failed. The goal is achieved only when every criterion is true:
func (e Evaluation) Satisfied() bool {
for _, r := range e.Results {
if r.Truth != True { return false }
}
return len(e.Results) > 0
}
After a restart with the taxi confirmed and the table unresolved, the taxi criterion is true and the table criterion is unknown, whatever a model might say. A plan that finishes while a criterion is not true is stopped with criteria_unsatisfied instead of being reported as done.
Effects that carry consequences also wait for a person. A capability can declare RequiresApproval, and the compiler puts a wait in front of every step that uses it. See Approvals that cannot go stale.
Stopping is recorded work
When you say “forget dinner”, the application records an ABANDON command and the engine decides what it means. It stops starting new steps. A result that arrives afterwards still goes into the ledger, because the effect did happen, but it changes no fact of the goal. Killing the worker is not cancellation. It is a crash, and a durable engine will faithfully resume the work you wanted stopped.
What Robotelos does not do yet
- No automatic compensation. The built-in capabilities have no cancellation. When one exists, it will be a capability like the others, with its own approval, its own key and its own recorded outcome. The design rule is that undo is more work, not a special case.
- One step at a time. The tree is a sequence. A plan in which the taxi proceeds while the table waits is not what runs today. That costs time and buys simplicity.
- Small plans. The goal strategy handles plans of up to three steps today and is experimental. What you can use today tracks it.
Takeaways
- List what each step can undo, and sort the plan so irreversible steps come last.
- Gate a step on the recorded outcome of the one before, and define success as the promised result.
- Evaluate goals on facts with an explicit “unknown”, so a missing fact is never read as a failure or a success.
- Treat stop and cancel as recorded work with their own evidence.
