|
Download README.md from Mastyf-Labs/foresight: direct link, hf CLI and curl.
- Browser
- Download file 9.01 kB
-
https://huggingface.co/Mastyf-Labs/foresight/resolve/main/README.md
- Command line
-
hf download hf://Mastyf-Labs/foresight/README.md
-
curl -L -o README.md https://huggingface.co/Mastyf-Labs/foresight/resolve/main/README.md
9.01 kB
| license: other | |
| license_name: mastyf-proprietary | |
| language: [en] | |
| tags: [agent-security, ai-safety, tool-use, guardrails, prompt-injection, mcp, agents] | |
| pipeline_tag: text-classification | |
| <p align="center"> | |
| <img src="https://huggingface.co/Mastyf-Labs/foresight/resolve/main/assets/hero.svg" alt="Mastyf Foresight predicting that a curl command will send AWS credentials off the machine, and escalating" width="880"/> | |
| </p> | |
| <p align="center"> | |
| <a href="https://mastyf-foresight.onrender.com/"><b>Try it live</b></a> · | |
| <a href="#watch-it-catch-an-attack">Watch it catch an attack</a> · | |
| <a href="#results">Results</a> · | |
| <a href="https://www.mastyf.ai/">mastyf.ai</a> | |
| </p> | |
| **Mastyf Foresight** reads the next tool call an AI agent wants to make (a shell command, a file write, a SQL | |
| query, a URL) and predicts **what it will actually do** before it runs: which secrets it touches, whether data | |
| leaves the machine, what it deletes, what it installs, and how bad it could get. | |
| Most guardrails ask whether text *looks* like an attack. Foresight asks what happens if the action is allowed to run. | |
| --- | |
| ## Watch it catch an attack | |
| An agent is asked to set up a project. The README it reads carries a hidden instruction. Every step is judged | |
| **before it runs**, and Foresight also sees what earlier tools returned, including the planted comment. | |
| <p align="center"> | |
| <img src="https://huggingface.co/Mastyf-Labs/foresight/resolve/main/assets/replay.svg" alt="Step-by-step replay: reading the README and installing requirements are allowed; reading the AWS credentials and posting them out are escalated; the agent is paused at step 3" width="880"/> | |
| </p> | |
| ## What it sees in a single action | |
| <p align="center"> | |
| <img src="https://huggingface.co/Mastyf-Labs/foresight/resolve/main/assets/actions.svg" alt="Six actions with their predicted effects: tests and README reads are allowed; dumping the users table, download-and-run, leaking AWS keys over HTTPS and copying an SSH key are escalated" width="880"/> | |
| </p> | |
| Every card is a real prediction, not a mock-up. Foresight names **39 effects**, among them reading secrets, | |
| sending a secret off the machine, installing persistence, piping downloaded code into a shell, dumping a database | |
| and touching cloud metadata, and gives a **95% worst-case bound** on bytes sent out, database rows exposed and | |
| files deleted. | |
| ## How it learned | |
| <p align="center"> | |
| <img src="https://huggingface.co/Mastyf-Labs/foresight/resolve/main/assets/how.svg" alt="01 Sandbox, 02 Observed labels, 03 Foresight, 04 Built for Shield" width="880"/> | |
| </p> | |
| Foresight did not learn from opinions about what looks dangerous. Each of its 85,000+ training actions was run in | |
| an isolated container with planted fake credentials, system-call tracing and a network trap that also decrypts | |
| HTTPS and acts as an SSH and SFTP server. If a planted key appeared on the wire, the action really leaked a secret. | |
| The model learns to predict those **observed consequences** from the action and the session so far. | |
| ## Results | |
| <p align="center"> | |
| <img src="https://huggingface.co/Mastyf-Labs/foresight/resolve/main/assets/results.svg" alt="Attacks caught: Claude Agent SDK 98.4%, OpenAI Agents SDK 89.8%, Google ADK 85.5%; normal sessions flagged 0.4 to 1.4%" width="880"/> | |
| </p> | |
| <details> | |
| <summary><b>Full numbers and how they were measured</b></summary> | |
| Simulated deployments built from public agent traces. Thresholds are set on the first half of each deployment's | |
| own traffic (its burn-in) and every number is measured on the second half. Attacks come from attack categories | |
| held out of training. | |
| | Deployment | Held-out attacks caught | Normal sessions with any false alarm | | |
| |---|---|---| | |
| | Claude Agent SDK | 98.4% | 1.4% | | |
| | OpenAI Agents SDK | 89.8% | 0.6% | | |
| | Google ADK, never seen in training | 85.5% | 0.4% | | |
| | mini-swe-agent, never seen | — | 4.7%; fresh sessions calibrated on fresh traffic: 1.0% | | |
| | OpenHands, never seen | — | 3.7%; fresh sessions calibrated on fresh traffic: 0.0% | | |
| - Attacks a sandbox confirmed did real harm: **96–100%** caught. | |
| - Held-out secret leaks over **HTTPS, SSH and SFTP**: **98–100%** caught, with 0–1.4% of look-alike normal network actions flagged. | |
| - Fail-safe: 2,000 fault-injected decisions and **0** cases where a model failure made a decision more permissive. | |
| All numbers are self-measured on public data; see Limitations. | |
| </details> | |
| ## Try it live | |
| The interactive demo lets you type any action, or replay a whole agent session step by step. | |
| **[mastyf-foresight.onrender.com](https://mastyf-foresight.onrender.com/)** | |
| Type any action, or replay a whole agent session step by step and watch where Shield would pause the agent. | |
| Actions are only analysed, never executed. The page loads instantly; after a quiet period the model itself can | |
| take up to 30 seconds to wake, and the page shows when it is ready. | |
| ## How it compares | |
| Judging an agent's action before it runs became an active research area in 2025–26. Foresight's design differs | |
| from the strongest published guards in where its ground truth comes from, what it tells you, and what it needs to run. | |
| | System | Ground truth | Model | Tells you | | |
| |---|---|---|---| | |
| | **Mastyf Foresight** | **Observed in an instrumented sandbox** (85,000+ executed actions) | **39M**, built from scratch, CPU | 39 effects, harm, **95% damage bounds**, off-task | | |
| | DreamGuard (2026) | GPT-5.1 pre-labels reviewed by people | World model on a frozen Qwen3-4B encoder | Pass / hold / block | | |
| | StepGuard (2026) | LLM-simulated tool responses, LLM labels | Qwen3-4B fine-tuned | Safe / unsafe, risk type | | |
| | JANUS · Vanguard (2026) | Simulated tools, GPT-5.5 labels | Qwen3-8B fine-tuned | Safe / potentially unsafe / unsafe | | |
| | LlamaFirewall AlignmentCheck (2025) | Prompted large model | Llama 4 Maverick | Aligned / misaligned | | |
| Foresight is not a chat model and follows no instructions, so there is no prompt for injected text to hijack | |
| (adaptive attacks are not yet tested). Published figures come from different benchmarks and hardware, so this is | |
| a design comparison, not a head-to-head. Sources: arXiv | |
| [2608.05695](https://arxiv.org/abs/2608.05695), [2608.24777](https://arxiv.org/abs/2608.24777), | |
| [2607.19913](https://arxiv.org/abs/2607.19913), [2505.03574](https://arxiv.org/abs/2505.03574). | |
| **[Explore the benchmarks interactively](https://mastyf-foresight.onrender.com/#bench)**: pick a deployment, move | |
| the alarm budget, and see catches and false alarms change, measured on held-out data. | |
| ## Built for Mastyf Shield | |
| Foresight is designed to run inside [Mastyf Shield](https://www.mastyf.ai/) as an **advisor**: it can only make a | |
| decision stricter (warn or escalate), never looser, and if it errors or is slow, Shield decides without it. It | |
| complements **Protocol X**, which checks the content agents read, and **Mastyf Authority**, which caps the damage | |
| any account can do. Foresight checks the actions agents take, and its damage bounds (bytes out, records | |
| exposed, files deleted) map onto the kinds of limits Authority enforces. | |
| ## Model details | |
| | | | | |
| |---|---| | |
| | Architecture | Causal byte-level transformer, 39M parameters, built and trained from scratch by Mastyf Labs | | |
| | Context | The whole session (2,048 bytes of history), the user's task, and digests of earlier tool outputs | | |
| | Outputs | 39 effect probabilities, harm score, damage bounds (q95), off-task score | | |
| | Tools covered | Shell, file read, write and edit, search, URLs, SQL, code execution | | |
| | Speed | About 50 ms per decision on a laptop CPU; an int8 version runs on small servers | | |
| | Availability | Through Mastyf Shield. **Weights are not distributed.** | | |
| ## Limitations | |
| - **Simulated, not production, traffic.** Deployments are built from public agent traces; no live customer data yet. | |
| - **Coding, shell and file-system agents are covered best.** Business-tool domains it has never seen, for example | |
| an HR or healthcare application, are not yet reliable; this is the focus of the next version. | |
| - **Harm only in the final answer is out of scope.** If every tool call is legitimate and the harm is in what the | |
| agent writes back, for example a wrong treatment plan, an action model cannot see it; that needs a separate | |
| check on the answer. | |
| - **Fixed public attack sets.** Not yet tested against attackers who adapt to the model. | |
| - **Calibrate per deployment.** Thresholds must be set on the customer's own recent traffic. | |
| ## Acknowledgements | |
| Built with public data from DTap-Bench (Apache-2.0), SWE-smith trajectories (MIT), mini-swe-agent trajectories | |
| (MIT), DeepSWE trajectories (MIT) and NVIDIA SWE-Zero OpenHands trajectories (CC-BY-4.0). Thanks to their authors. | |
| <p align="center"> | |
| <img src="https://huggingface.co/Mastyf-Labs/foresight/resolve/main/assets/logo_badge.png" alt="Mastyf" width="48"/><br/> | |
| <sub><b>Mastyf Labs</b> · perimeter security for AI · supported by the IIT Kharagpur Seed Fund</sub> | |
| </p> | |