
[](LICENSE)
[](https://www.python.org/downloads/)
[](https://arxiv.org/abs/2601.12822)
**Train in the MirrorWorld, Act in the Wild.**
**MirrorGuard: Toward Secure Computer-Use Agents via Simulation-to-Real Reasoning Correction**
**WhitzardAgent | Shanghai Innovation Institute (SII) | Fudan University**
[Paper](https://arxiv.org/abs/2601.12822) | [Project Page](https://bmz-q-q.github.io/MirrorGuard/) | [Model](https://huggingface.co/WhitzardAgent/MirrorGuard) | [Chinese README](README_zh.md)
## Overview
MirrorGuard is a plug-and-play defense framework for computer-use agents (CUAs). Instead of relying on coarse action blocking, MirrorGuard intervenes at the reasoning layer: it intercepts an agent's insecure thought, corrects it into a secure reasoning path, and then steers the agent toward a safer action.
The framework has two tightly connected parts:
- **MirrorWorld**: a neural-symbolic simulation environment for synthesizing security-related agentic trajectories in pure text.
- **MirrorGuard**: a deployed reasoning-correction module that transfers the learned security logic to real GUI agents.
This repository contains both the training-side pipeline and OSWorld-style integration examples that show how MirrorGuard is embedded into real agents.
MirrorGuard is released as a WhitzardAgent project and should remain attributable to the Fudan University and Shanghai Innovation Institute (SII) team behind the work.
Most importantly, the released [WhitzardAgent/MirrorGuard](https://huggingface.co/WhitzardAgent/MirrorGuard) model is the final **VLM** trained on reasoning-correction data produced by the MirrorWorld synthesis and dataset-generation pipeline in this repository.
## From Code To Model
MirrorGuard should be read as a full pipeline rather than "some code plus a model card":
1. `task_generation/` and `simulator.py` construct risky and benign computer-use trajectories in **MirrorWorld**.
2. `dataset_generation/safe_thought.py` identifies unsafe reasoning and generates corrected safe reasoning.
3. `dataset_generation/prepare_dataset.py` converts those pairs into the final training format for MirrorGuard supervision.
4. The resulting reasoning-correction corpus is used to fine-tune the released **MirrorGuard VLM** on Hugging Face.
5. That trained VLM is then deployed as the runtime corrector used in the agent integration examples under `examples/`.
The key raw data files included in this repository are:
- `dataset_generation/train.jsonl`
- `dataset_generation/test.jsonl`
`prepare_dataset.py` is configured to package them into ShareGPT-style training files such as `dataset/sharegpt_train.jsonl` and `dataset/sharegpt_test.jsonl`.
## Qualitative Demo