Memory-augmented large language model (LLM) driving agents can reuse past experience, yet previously learned corrections often fail to transfer when traffic conditions change. A key limitation is that existing memories mainly record observed outcomes, providing little evidence about alternative actions. We introduce XMind, a training-free framework that enables LLM-based driving to "Think Twice" through cross-memory reasoning. XMind integrates working memory of recent traffic states with episodic memory of critical risk events. The agent first makes an initial decision from the current context and then cross-checks it against retrieved historical experience. If a conflict arises, it makes a second decision guided by the retrieved evidence. To construct reliable episodic memory, XMind evaluates alternative actions through counterfactual rollouts under perturbed traffic conditions and stores the verified outcomes as structured risk capsules. These capsules are retrieved by jointly matching spatial risk patterns and scenario semantics. Across closed-loop highway simulations, XMind achieves success rates of 83.3-93.3%, exceeding the strong baseline by 6.6 percentage points on average. Evaluation on K-Risk further demonstrates lower decision risk on unseen real-world high-risk interactions. Ablation studies confirm the complementary benefits of working memory, risk-text retrieval, and counterfactual verification. Code is available at https://github.com/xiangxiangliuwo/XMind
Figures & tables
Fig. 1: From reflection-based correction to “Think Twice” reasoning. Top: LLM reflection suggests a correction without counterfactual verification of recoverability. Bottom: XMind tests candidate actions under traffic perturbations and continuation policies, stores the resulting evidence in episodic risk capsules, and triggers “Think Twice” cross-memory reasoning when retrieved evidence disagrees with the initial decision.
Fig. 2: Overview of XMind. Working memory provides recent traffic context and a spatial risk layout. Online decision-making uses risk-gated episodic retrieval to cross-check the initial decision, triggering “Think Twice” reasoning when the retrieved preferred action differs from the initial choice. Offline validation evaluates candidate actions at critical states through counterfactual rollouts, distinguishing recoverable, dangerous, and uncertain actions. The resulting evidence is stored as risk capsules in episodic memory for reuse across episodes. The LLM parameters remain frozen throughout the whole process.
4 lanes, density 2.5
5 lanes, density 2.5
5 lanes, density 3.0
Tokens/step
Method
SR ↑
SS ↑
vˉ↑
TTCmin↑
SR ↑
SS ↑
vˉ↑
TTCmin↑
SR ↑
SS ↑
vˉ↑
TTCmin↑
Input ↓
Output ↓
DiLu [ 1 ]
70.0
22.13
12.99
6.33
73.3
23.27
15.15
5.57
46.7
16.47
13.32
4.63
≈ 2000
≈ 60
KoMA ∗ [ 4 ]
73.3
23.00
13.84
5.44
66.7
22.63
15.83
4.66
60.0
20.37
14.89
4.43
≈ 5800
≈ 200
RESPOND [ 5 ]
86.7
26.37
12.29
6.44
83.3
26.46
12.94
6.18
76.7
24.63
10.61
5.70
≈ 1000
≈ 50
XMind (ours)
93.3
28.13
10.74
7.19
90.0
27.53
11.65
5.62
83.3
25.77
10.98
4.44
≈ 3100
≈ 180
TABLE I: Comparison of driving performance and token usage across highway scenarios with different lane counts and traffic densities. Bold and underlined values indicate the best and second best results, respectively. This convention applies to all subsequent tables.
Event type
highD [ 29 ]
NGSIM [ 30 ]
extreme [ 31 ] ∗
Hard braking
42
35
38
Left cut in
23
30
-
Right cut in
21
42
-
Total
86
107
38
TABLE II: Counts of selected events across the K-Risk subsets.
Dataset
Method
Safer
Similar
Riskier
highD ( n=319 )
NoMem
15.36
77.12
7.52
30Mem
16.61
77.43
5.96
NGSIM ( n=468 )
NoMem
32.05
54.70
13.25
30Mem
35.26
51.28
13.46
extreme ( n=138 )
NoMem
21.01
68.84
10.15
30Mem
21.01
66.67
12.32
TABLE III: Pairwise safety comparison against Human (%).
Window N
SR (%) ↑
SS ↑
1
73.3
23.53
3
80.0
25.27
5
80.0
25.67
TABLE IV: Working memory window.
Fig. 3: Risk reduction and memory-guided decision revision on K-Risk. The bar chart shows mean peak risk reduction relative to Human at paired critical frames (higher is better). The scenario contrasts the recorded Human left lane change with XMind’s right lane change. The decision trace shows an initial SLOWER action, retrieval of a verified capsule, and a revised LANE_RIGHT decision. Prompt and reasoning excerpts are illustrative.
Method
Working
Episodic
Retrieval method
Counterfactual
SR (%) ↑
SS ↑
memory
memory
Text
Risk
verification
Without memory
×
×
×
×
×
50.0
17.03
Working memory only
✓
×
×
×
×
66.7
21.40
Text retrieval
✓
✓
✓
×
✓
73.3
23.03
Risk retrieval
✓
✓
×
✓
✓
80.0
24.83
w/o counterfactual verification
✓
✓
✓
✓
×
78.9
24.54
TABLE V: Ablation study with five lanes and a traffic density of 3.0. Text and Risk denote the two retrieval methods.