arXiv:2610.39775cs.ROOct 2026

Manuscript Offprint

arXiv:2610.39775

Teaching a Tree to Recover: Online Distillation of an LLM Supervisor with Counterfactual Replay

Kristian Ceder, Kilian Freitag, Knut Åkesson

Kristian Ceder Kilian Freitag Knut Åkesson

Department of Electrical Engineering, Chalmers University of Technology, Sweden

{cederk, kilian.freitag, knut.akesson}@chalmers.se

Abstract: Autonomous mobile robots commonly pair a global planner with a local model predictive controller (MPC), but nonconvex obstacle avoidance and a limited horizon can make the robot freeze in complex layouts. Deciding whether to replan, wait, or call for help is a supervisory decision. Recent work queries a large language model (LLM) supervisor on every anomaly, which is slow and costly. We instead distill the LLM online into a decision tree. After each training episode, counterfactual replay labels recoveries as needed, unnecessary, or harmful. These labels retire unhelpful rules. In simulation, on 20 unseen layouts where the MPC alone freezes, the tree handles at least 18 correctly across all seeds, either by reaching the goal or by calling for help when no feasible path exists. The tree matches both an always-query LLM supervisor and expert-designed rules, while issuing no LLM queries at test time. Handwritten rules cannot anticipate the long tail of situations a physical robot will encounter. Online distillation is a promising remedy: the tree handles familiar cases, and the LLM is consulted only for new ones, whose validated recoveries become new rules. Language models can thus also serve as designers of supervisors rather than only as runtime supervisors.

Keywords: Failure recovery, LLM supervision, Decision trees, Model predictive control, Counterfactual evaluation

Figure

recoveries

98% of decision by tree

LLM calls

reduce 1.8 → 0.1

90% validation

layout success

99% training

layout success

Figure 1: An LLM teaches a decision tree to recover an MPC-driven robot, then leaves the loop. Left: the tree answers what it has seen, the teacher the rest. Right: the experience memory, built by counterfactual replay: the three recoveries of one learning layout, each re-run without itself and labeled needed, unnecessary (no difference) or harmful (cost time); the labels retire rules that only look right and are shown to the teacher in context. Bottom: 200 learning layouts, three runs.

1 Introduction

Autonomous Mobile Robot (AMR) navigation is commonly split into two layers. A global planner computes a path over a map, typically with Dijkstra's algorithm or A*, treating the robot as a point and ignoring its kinematic and dynamic constraints. A local controller, often a model predictive controller (MPC), tracks this path while respecting those constraints, and may deviate from it temporarily to avoid static and dynamic obstacles. Such deviations must stay small, because obstacle avoidance makes the optimization problem nonconvex: with a finite horizon, the solver is prone to local optima, slow or failed convergence, and exceeding its computation budget. When the path is blocked by a large or non-convex obstacle that is missing from the map, such as a blocking object across an aisle or a U-shaped arrangement of pallets, a way around it lies beyond what the controller can find, and the robot comes to a standstill. Whether it should then replan, wait, or call for help depends on the cause. This decision belongs to a supervisory layer above the controller. Navigation stacks typically implement this layer as hand-written recovery behaviors triggered when the planner or controller fails [1]. In this work, we investigate how to learn this recovery behavior. Recent work places a large language model (LLM) in the loop as a supervisor [2, 3, 4] and queries it on every anomaly, at a latency of seconds.

This paper studies a similar approach where an LLM is used to find effective failure recoveries for an MPC-controlled mobile robot based on our previous work [5, 6]. Unlike other approaches, we study where a decision should reside once it has been made a few times by abstracting and refining recurring events into a decision tree. Further, in subsequent loops, the decision tree is first queried, and only when no fitting decision is present the LLM is queried again for additional labels. Therefore, the cost of decisions drastically decreases over time. To refine and verify decisions in the tree, we use counterfactual replay of each action after an episode finishes, which enables in-context learning for the LLM supervisor. Through this, the LLM can continuously improve its decisions and update the decision tree.

In various simulated scenarios, we find that our method complement and assist the MPC controller, leading to a near-perfect success rate in our tests. Importantly, it performs on par with hand-designed rules specifically created for the tested scenarios, showing that our framework can adapt to and learn from observed scenarios without human supervision.

In 20 held-out test layouts where the MPC alone fails, we show that our method instead succeeds in reaching the goal position in more than 90% of the cases. Furthermore, when comparing our method with a baseline of scripted rules specifically designed for those scenarios, we find that our method automatically finds equal or better decisions while reaching the goal in 10% fewer steps, thus verifying its effectiveness at finding reasonable interventions.

Our contributions are:

• Online distillation of an LLM for AMR failure recovery into a decision tree. At a regular interval, a language model reads the current status report and decides whether an intervention is needed and picks a predefined recovery action, which acts only through the reference of an MPC tracker, the robot never waits for the LLM. To reduce the cost of repetitive interventions, we distill the LLM supervisor's actions online into a decision tree when they occur more than once.

• Counterfactual replay for in-context learning and rule-retirement. We show that when having access to a simulator then re-simulating each situation without the supervisor’s intervention gives labels if the action was needed, unnecessary, or harmful. Those are then used to retire existing rules and train the LLM in context to improve future decisions.

The code, data and videos are available at:

https://github.com/kristianceder/Counterfactual-Tree-Teaching.

References (18)