# Learning Inside Types: Epistemic Typestates for Safe Multi-Agent Reinforcement Learning

> Epistemic typestates mask unsafe actions using each agent’s beliefs and public peer types, so policies can learn without runtime communication. Across nine benchmarks, typed learners caused no safety violations; VMAS IPPO’s Lagrangian baseline logged 2540±16 agent-caused collision onsets per training run.

- arXiv: https://arxiv.org/abs/2611.27631
- Authors: Lorenzo Bacchiani, Mario Bravetti, Giovanni Pau, Roberto Girau
- Published: 2026-11-24
- Topic: RL & post-training
- Visual carousel: https://instaxiv.com/p/2611.27631
- Explanation by InstaXiv, a secondary educational summary. Cite the original paper for exact results. InstaXiv is not affiliated with or endorsed by arXiv or Cornell University.

## Can each agent learn safely from its own partial view?

**0 vs 2540±16** VMAS IPPO collision onsets: type vs Lagrangian

## A penalty cannot rule out every unsafe move

**Expected-cost RL:** A cost budget discourages violations but does not exclude every unsafe transition during policy learning.

**Epistemic type:** A sound type masks unsafe modeled successors; any policy choosing permitted actions stays safe in training and execution. A shield is the full-observation, single-start, no-declaration case.

## A type follows what the agent can know

1. **Keep possible worlds**: Track worlds consistent with local actions and observations, including hidden states.
2. **Hidden values matter**: Car 1 sees (0,2,11); hidden car-3 speed and car-2/car-3 gap can be (2,10) or (0,9), changing car 2’s safe choices.
3. **Mask and update**: Permit actions only if every modeled successor is safe and each observation has a next type state; update the belief after acting.

## At native sizes, local builds finish faster

![Figure 3](https://cdn.instaxiv.com/figures/2611.27631/figure3.webp)

Panel (a), native populations: local type build 0.001-0.58 s; Adalat profile search 8.4-379.5 s. Panel (b), 2/5/10 agents: Adalat found no certified Car Platoon profile at 5/10; LBF did not finish within 32 GiB. (Figure 3)

## Build and compose local safety types

1. **Public bounds**: Public types bound peer actions/safety; declarations commit without messages.
2. **Finite synthesis**: From the initial belief, prune one-step-safe candidates without continuations to a fixed point; synthesis needs finite reachable beliefs and consistent declarations.
3. **Prove composition**: Rocq proves sound, complete synthesis, maximal per-belief permissiveness without obligations; team safety needs local model coverage and acyclic post-step reliance.
4. **Guard infinite worlds**: Without declarations, observation guards avoid enumeration, always offer an action and keep successors in a safe region containing all starts.

## Guard-built types: zero training collision onsets

| Method | MPE IPPO | MPE IQL | VMAS IPPO | VMAS IQL |
| --- | --- | --- | --- | --- |
| Lagrangian | 17231 | 35382 | 2540 | 2735 |
| **Typestate** | **0** | **0** | **0** | **0** |

_Agent-caused collision onsets per training run; means over five seeds, SE omitted. Paper’s Continuous benchmarks table._

## Safety does not settle the reward question

**Typed vs Lagrangian:** In MPE, types improved landmark counts and returns with both learners; VMAS IQL also improved both.

**VMAS IPPO trade-off:** Lagrangian IPPO returned more (31.6±0.3 vs 30.2±0.2), while typed IPPO reached more robot goals (2.561±0.189 vs 1.136±0.071 of six; mean ± SE, five seeds).

## Same local view, comparable Car Platoon costs

| Method | 2 followers | 5 followers | 10 followers |
| --- | --- | --- | --- |
| Brorholt shield | 5580.5 | 14961.8 | 31477.7 |
| **Typestate (−1.0% at 2)** | **5526.6** | **14669.0** | **32146.7** |

_Summed follower cost; lower is better. Means over 10 repetitions; SE omitted. Same UPPAAL learner/local inputs; differences not significant._

## Safety held; shield comparisons need context

**Typed vs unshielded:** Across nine benchmarks, typed learners caused no training or evaluation violations in any seed. Unshielded Traffic Junction averaged 100554 (IPPO) and 182115 (IQL) agent-caused crash onsets per training run (5-seed mean; SE omitted).

**Adalat comparison:** Five of 12 returns tied on every seed; differences went both ways, with one significant. In two-follower Car Platoon IPPO, type cost rose 10.7%; Adalat’s mask read state no agent could sense. IQL’s 3.4% rise was not significant.

## Safety still leaves room to choose

![Figure 4](https://cdn.instaxiv.com/figures/2611.27631/figure4.webp)

Other points summarize evaluation decisions; bars show one standard error over five seeds. Brorholt averages shared reachable states uniformly: types retain every shield-permitted action, 85.31% vs 85.05%, adding actions in 91 states. (Figure 4)

## What the guarantee assumes

- **Model fidelity**: Actual transitions must fit local models and peers honor public types; tests cannot prove soundness.
- **Finite beliefs**: Synthesis needs finitely many reachable beliefs and can be exponential in world count.
- **Guard limits**: Continuous guards rely on numerical arguments, not a verified checker; actions are finite, and safety alone does not ensure task progress.

## Key takeaways

- The key shift is enforcing safety at the action boundary, not learning from violations.
- Practitioners need sound local models, public bounds and observation-based guards for infinite worlds.
- The next challenge is learning models and verifying guards automatically, especially for continuous systems.

## Links

- arXiv: https://arxiv.org/abs/2611.27631
- PDF: https://arxiv.org/pdf/2611.27631

## Citation

```bibtex
@article{bacchiani2026learning,
  title   = {Learning Inside Types: Epistemic Typestates for Safe Multi-Agent Reinforcement Learning},
  author  = {Bacchiani, Lorenzo and Bravetti, Mario and Pau, Giovanni and Girau, Roberto},
  journal = {arXiv preprint arXiv:2611.27631},
  year    = {2026},
  url     = {https://arxiv.org/abs/2611.27631}
}
```
