sriram1983007 commited on
Commit
9e8dfce
·
verified ·
1 Parent(s): 2b59836

Card: cleaner header, grouped links, long examples folded

Browse files
Files changed (1) hide show
  1. README.md +44 -7
README.md CHANGED
@@ -92,8 +92,29 @@ model-index:
92
  ---
93
 
94
 
 
 
 
95
  # 🛡️ SRA-RiskGate-4B
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1R9seZu-En9QUZCklxFeIqxEuSaISg7x6)
98
  [![Kaggle dataset](https://img.shields.io/badge/Kaggle-Dataset-20BEFF?logo=kaggle&logoColor=white)](https://www.kaggle.com/datasets/sriram1983007/sra-stablecoin-risk-bench)
99
  [![Run on Kaggle](https://img.shields.io/badge/Kaggle-Run%20free%20on%20GPU-20BEFF?logo=kaggle&logoColor=white)](https://www.kaggle.com/code/sriram1983007/try-sra-riskgate-4b-payment-safety-model)
@@ -122,6 +143,8 @@ model-index:
122
  [![Mainnet check](https://img.shields.io/badge/Mainnet%20check-Robinhood%20Chain%20%C2%B7%20USDG-00C805?style=for-the-badge&logo=robinhood&logoColor=white)](https://gist.github.com/sriram1983007-dev/1d915320d85c7ed12a6044e42b382a40)
123
  [![Stablecoins](https://img.shields.io/badge/Stablecoins-USDC%20%C2%B7%20USDT%20%C2%B7%20USDB%20%C2%B7%20USDG%20%C2%B7%20any%20USD%20token-2775CA?style=for-the-badge)](https://github.com/sriram1983007-dev/sra-riskgate#usdt-usdb-and-usdg-100)
124
  ![Page views](https://hits.sh/huggingface.co/sriram1983007/SRA-RiskGate-4B.svg?style=for-the-badge&label=Page%20views&color=6b3fe0&labelColor=555555)
 
 
125
 
126
  **SRA-RiskGate-4B checks a stablecoin payment before an AI agent sends it, and answers `approve`, `hold` or `reject`** with reason codes. It is a 4B model, fine-tuned from `Qwen/Qwen3-4B-Instruct-2507`, that runs on a laptop.
127
 
@@ -142,13 +165,17 @@ Of v2's 3 unsafe approvals, 2 were prompt injections that the companion SDK's de
142
 
143
  **This page is v2 (2026-11-13).** The merged weights here, the [GGUF builds](https://huggingface.co/sriram1983007/SRA-RiskGate-4B-GGUF) and the [Q4_K_M file](https://huggingface.co/sriram1983007/SRA-RiskGate-4B-Q4_K_M-GGUF) are v2: SRA score 0.913 → **0.960**, dispute accuracy 77.8% → **90.2%**, wrongful denials 26.0% → **2.1%**, unsafe payment approvals 0.47% → **0.35%** ([v2 results](https://huggingface.co/datasets/sriram1983007/sra-bench-results)). v1 stays available: `from_pretrained("sriram1983007/SRA-RiskGate-4B", revision="v1")`. The Ollama registry model is still v1 until it is updated. For disputes, pass the computed window in the prompt: `dispute_messages()` in `sra-riskgate` 1.3.0+ builds the exact prompt.
144
 
 
 
145
  📄 **Paper:** [SRA-RiskGate: A Benchmark and a 4B Model for Gating Stablecoin Payments Made by AI Agents](https://doi.org/10.5281/zenodo.23715017) (preprint, Zenodo) · [full write-up on Ready Tensor](https://app.readytensor.ai/publications/sra-riskgate-a-benchmark-and-a-4b-model-for-gating-stablecoin-payments-made-by-ai-agents-wihp3WytOoKOc1g7NXFsl) · [discuss on alphaXiv](https://www.alphaxiv.org/abs/2610.sra-riskgate-stablecoin-payment-safety)
146
 
147
  📝 **Tutorial:** [Stop your AI agent from signing an unlimited USDC approval](https://dev.to/sriram1983007/stop-your-ai-agent-from-signing-an-unlimited-usdc-approval-10c0): three deterministic checks to run before an agent signs, with runnable code.
148
 
149
  📝 **Article:** [No Chargebacks for AI Agents: Check Payments Before They Sign](https://sriram1983007.hashnode.dev/no-chargebacks-for-ai-agents-check-payments-before-they-sign): how ACP, AP2, MPP and x402 compare, and why stablecoin payments need a risk check before the agent signs.
150
 
151
- 🔁 **Verified in the open (November 2026).** The companion `sra-riskgate` library's checks, in front of real agents:
 
 
152
 
153
  - **Base Sepolia, independently re-checked:** an approved 0.01 USDC payment ([tx](https://sepolia.basescan.org/tx/0xf12e9084becefd94fa6e26e54761fbfc8f3c04215d7fc724d0fca6077ba084fc)) was read back from the chain and verified, and a 2.00 USDC payment to an unknown payee was held before signing. Flow Executor, an independent agent settlement verifier, re-checked both from the chain ([log](https://gist.github.com/sriram1983007-dev/35eab0e934a512346193bcdb5b12d9cf) · [Flow Executor's page](https://flow-kg4x.vercel.app/row)).
154
  - **Circle Gateway on Arc testnet:** one agent task, three proposed payments. One was approved, accepted by Gateway and settled to the payee (agent 0.09 → 0.08 USDC, payee 0.01 → 0.02); an unlimited approval was held and a look-alike payee rejected, neither signed ([log](https://gist.github.com/sriram1983007-dev/8cd44e78adec20a0157368ec38c2fb42)).
@@ -263,6 +290,9 @@ pip install "sra-riskgate[agentkit]>=0.8.0"
263
 
264
  Register `RiskGateActionProvider` as the payment provider on your AgentKit instance. It checks chain support, policies, and peg deviations, executing safe ERC-20 transfers only after approval:
265
 
 
 
 
266
  ```python
267
  from coinbase_agentkit import AgentKit, AgentKitConfig, CdpEvmWalletProvider, CdpEvmWalletProviderConfig
268
  from sra_riskgate.integrations.agentkit import RiskGateActionProvider
@@ -295,6 +325,8 @@ agent_kit = AgentKit(AgentKitConfig(
295
  ))
296
  ```
297
 
 
 
298
  > **Security Guardrail:** To ensure the firewall cannot be bypassed by an autonomous agent, register `RiskGateActionProvider` as the **sole** payment action provider. Do not register generic native transfer or unconstrained ERC-20 providers alongside it.
299
 
300
  ### Deterministic Pre-Execution Rules
@@ -324,6 +356,9 @@ The model was trained on a specific prompt format, and it only performs as bench
324
 
325
  Disputes use a different system prompt and user template. See the `prompt` column of the dataset's [`sft` split](https://huggingface.co/datasets/sriram1983007/sra-stablecoin-risk-bench) for exact dispute examples.
326
 
 
 
 
327
  ```python
328
  import json
329
  from datetime import datetime, timezone
@@ -482,6 +517,8 @@ verdict = parse_verdict(raw_output)
482
  print(json.dumps(verdict, indent=2))
483
  ```
484
 
 
 
485
  ### Example Output (`risk_gate`)
486
 
487
  For the request above, the expected verdict is a hold: the payee's trusted attestation rates it high risk, and the payer's attestation comes from an attester that is not on the policy's trusted list.
@@ -510,7 +547,7 @@ For the request above, the expected verdict is a hold: the payee's trusted attes
510
  ollama run sriram1983007/sra-riskgate
511
  ```
512
 
513
- The Ollama build has the **payment risk-gate system prompt** built in, plus `temperature 0` and an 8K context. Send the user message in the training format shown in the Quickstart (`Evaluate this stablecoin payment.` followed by the `<context>`, `<payload>` and `<tool_results>` blocks).
514
 
515
  For **dispute adjudication**, pass the dispute system prompt in your request (it replaces the built-in one). The exact text is in the `prompt` column of the dataset's [`sft` split](https://huggingface.co/datasets/sriram1983007/sra-stablecoin-risk-bench).
516
 
@@ -518,11 +555,11 @@ For **dispute adjudication**, pass the dispute system prompt in your request (it
518
 
519
  | Repo | What's in it |
520
  | --- | --- |
521
- | [SRA-RiskGate-4B-Q4_K_M-GGUF](https://huggingface.co/sriram1983007/SRA-RiskGate-4B-Q4_K_M-GGUF) | Official Q4_K_M (2.5 GB), the build behind the Ollama model |
522
- | [SRA-RiskGate-4B-GGUF](https://huggingface.co/sriram1983007/SRA-RiskGate-4B-GGUF) | Official GGUF builds |
523
- | [mradermacher/SRA-RiskGate-4B-i1-GGUF](https://huggingface.co/mradermacher/SRA-RiskGate-4B-i1-GGUF) | Community imatrix quants by mradermacher, usually the better choice at small sizes |
524
- | [mradermacher/SRA-RiskGate-4B-GGUF](https://huggingface.co/mradermacher/SRA-RiskGate-4B-GGUF) | Community static quants by mradermacher |
525
- | [tinyopsec/SRA-RiskGate-4B-GGUF](https://huggingface.co/tinyopsec/SRA-RiskGate-4B-GGUF) | Community quants by tinyopsec, Q2_K to F16 (builds below Q4 not evaluated) |
526
 
527
  The benchmark figures below are for the full-precision model. The v2 GGUF files were checked on 12 benchmark cases (12 of 12 correct for both Q8_0 and Q4_K_M) but have not yet been run on the full benchmark. The full-benchmark quantized results here are for the **v1** builds (measured 2026-11-11; still available at revision `v1`): **Q8_0 matches full precision** on every safety metric; **Q4_K_M keeps the payment gate** (99.3% accuracy, no legitimate payment blocked, unsafe approvals 0.83% vs 0.47%) **but is weaker on disputes** (67.4% vs 77.8%), mostly from false "outside the dispute window" claims that `check_dispute_verdict` corrects (wrongful denials 0.85% with the check, on every build). Use Q4_K_M for payment checks and Q8_0 or full precision for disputes; all predictions are in [sra-bench-results](https://huggingface.co/datasets/sriram1983007/sra-bench-results).
528
 
 
92
  ---
93
 
94
 
95
+ <!-- card layout 2026-11-13 -->
96
+ <div align="center">
97
+
98
  # 🛡️ SRA-RiskGate-4B
99
 
100
+ **An open safety check for stablecoin payments made by AI agents (x402, USDC, MCP). Runs on a laptop.**
101
+
102
+ [![Live demo](https://img.shields.io/badge/Live%20demo-try%20to%20trick%20it-blue?style=for-the-badge&logo=huggingface)](https://huggingface.co/spaces/sriram1983007/sra-riskgate-demo)
103
+ [![Ollama](https://img.shields.io/badge/Ollama-run%20locally-black?style=for-the-badge&logo=ollama)](https://ollama.com/sriram1983007/sra-riskgate)
104
+ [![PyPI](https://img.shields.io/pypi/v/sra-riskgate?style=for-the-badge&logo=pypi&label=sra-riskgate&color=blue)](https://pypi.org/project/sra-riskgate/)
105
+ [![MCP server](https://img.shields.io/pypi/v/sra-riskgate-mcp?style=for-the-badge&logo=pypi&label=MCP%20server&color=blue)](https://pypi.org/project/sra-riskgate-mcp/)
106
+ [![Paper](https://img.shields.io/badge/Paper-Zenodo-blue?style=for-the-badge&logo=zenodo)](https://doi.org/10.5281/zenodo.23715017)
107
+ [![Results](https://img.shields.io/badge/Results-all%20predictions%20published-brightgreen?style=for-the-badge&logo=huggingface)](https://huggingface.co/datasets/sriram1983007/sra-bench-results)
108
+
109
+ **v2 · 2026-11-13** · 99.6% payment decisions correct · 0.35% unsafe approvals · 90.2% dispute outcomes correct · 227 of 227 on real Base payments
110
+
111
+ [Try it](#try-it) · [Python SDK](#📦-python-sdk-one-call-before-every-payment-pypi) · [MCP](#🔌-use-it-from-an-ai-agent-mcp) · [Quickstart](#🚀-transformers-quickstart) · [Benchmark](#📊-benchmark-evaluation-held-out-test-split-measured-by-the-author) · [Limitations](#⚠️-limitations--verification-scope)
112
+
113
+ </div>
114
+
115
+ <details>
116
+ <summary><b>All links and badges</b> (notebooks, integrations, demos, on-chain proofs)</summary>
117
+
118
  [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1R9seZu-En9QUZCklxFeIqxEuSaISg7x6)
119
  [![Kaggle dataset](https://img.shields.io/badge/Kaggle-Dataset-20BEFF?logo=kaggle&logoColor=white)](https://www.kaggle.com/datasets/sriram1983007/sra-stablecoin-risk-bench)
120
  [![Run on Kaggle](https://img.shields.io/badge/Kaggle-Run%20free%20on%20GPU-20BEFF?logo=kaggle&logoColor=white)](https://www.kaggle.com/code/sriram1983007/try-sra-riskgate-4b-payment-safety-model)
 
143
  [![Mainnet check](https://img.shields.io/badge/Mainnet%20check-Robinhood%20Chain%20%C2%B7%20USDG-00C805?style=for-the-badge&logo=robinhood&logoColor=white)](https://gist.github.com/sriram1983007-dev/1d915320d85c7ed12a6044e42b382a40)
144
  [![Stablecoins](https://img.shields.io/badge/Stablecoins-USDC%20%C2%B7%20USDT%20%C2%B7%20USDB%20%C2%B7%20USDG%20%C2%B7%20any%20USD%20token-2775CA?style=for-the-badge)](https://github.com/sriram1983007-dev/sra-riskgate#usdt-usdb-and-usdg-100)
145
  ![Page views](https://hits.sh/huggingface.co/sriram1983007/SRA-RiskGate-4B.svg?style=for-the-badge&label=Page%20views&color=6b3fe0&labelColor=555555)
146
+
147
+ </details>
148
 
149
  **SRA-RiskGate-4B checks a stablecoin payment before an AI agent sends it, and answers `approve`, `hold` or `reject`** with reason codes. It is a 4B model, fine-tuned from `Qwen/Qwen3-4B-Instruct-2507`, that runs on a laptop.
150
 
 
165
 
166
  **This page is v2 (2026-11-13).** The merged weights here, the [GGUF builds](https://huggingface.co/sriram1983007/SRA-RiskGate-4B-GGUF) and the [Q4_K_M file](https://huggingface.co/sriram1983007/SRA-RiskGate-4B-Q4_K_M-GGUF) are v2: SRA score 0.913 → **0.960**, dispute accuracy 77.8% → **90.2%**, wrongful denials 26.0% → **2.1%**, unsafe payment approvals 0.47% → **0.35%** ([v2 results](https://huggingface.co/datasets/sriram1983007/sra-bench-results)). v1 stays available: `from_pretrained("sriram1983007/SRA-RiskGate-4B", revision="v1")`. The Ollama registry model is still v1 until it is updated. For disputes, pass the computed window in the prompt: `dispute_messages()` in `sra-riskgate` 1.3.0+ builds the exact prompt.
167
 
168
+ ### 📚 Paper and articles
169
+
170
  📄 **Paper:** [SRA-RiskGate: A Benchmark and a 4B Model for Gating Stablecoin Payments Made by AI Agents](https://doi.org/10.5281/zenodo.23715017) (preprint, Zenodo) · [full write-up on Ready Tensor](https://app.readytensor.ai/publications/sra-riskgate-a-benchmark-and-a-4b-model-for-gating-stablecoin-payments-made-by-ai-agents-wihp3WytOoKOc1g7NXFsl) · [discuss on alphaXiv](https://www.alphaxiv.org/abs/2610.sra-riskgate-stablecoin-payment-safety)
171
 
172
  📝 **Tutorial:** [Stop your AI agent from signing an unlimited USDC approval](https://dev.to/sriram1983007/stop-your-ai-agent-from-signing-an-unlimited-usdc-approval-10c0): three deterministic checks to run before an agent signs, with runnable code.
173
 
174
  📝 **Article:** [No Chargebacks for AI Agents: Check Payments Before They Sign](https://sriram1983007.hashnode.dev/no-chargebacks-for-ai-agents-check-payments-before-they-sign): how ACP, AP2, MPP and x402 compare, and why stablecoin payments need a risk check before the agent signs.
175
 
176
+ ### 🔁 Verified in the open (November 2026)
177
+
178
+ The companion `sra-riskgate` library's checks, in front of real agents:
179
 
180
  - **Base Sepolia, independently re-checked:** an approved 0.01 USDC payment ([tx](https://sepolia.basescan.org/tx/0xf12e9084becefd94fa6e26e54761fbfc8f3c04215d7fc724d0fca6077ba084fc)) was read back from the chain and verified, and a 2.00 USDC payment to an unknown payee was held before signing. Flow Executor, an independent agent settlement verifier, re-checked both from the chain ([log](https://gist.github.com/sriram1983007-dev/35eab0e934a512346193bcdb5b12d9cf) · [Flow Executor's page](https://flow-kg4x.vercel.app/row)).
181
  - **Circle Gateway on Arc testnet:** one agent task, three proposed payments. One was approved, accepted by Gateway and settled to the payee (agent 0.09 → 0.08 USDC, payee 0.01 → 0.02); an unlimited approval was held and a look-alike payee rejected, neither signed ([log](https://gist.github.com/sriram1983007-dev/8cd44e78adec20a0157368ec38c2fb42)).
 
290
 
291
  Register `RiskGateActionProvider` as the payment provider on your AgentKit instance. It checks chain support, policies, and peg deviations, executing safe ERC-20 transfers only after approval:
292
 
293
+ <details>
294
+ <summary>Show the AgentKit example (Python)</summary>
295
+
296
  ```python
297
  from coinbase_agentkit import AgentKit, AgentKitConfig, CdpEvmWalletProvider, CdpEvmWalletProviderConfig
298
  from sra_riskgate.integrations.agentkit import RiskGateActionProvider
 
325
  ))
326
  ```
327
 
328
+ </details>
329
+
330
  > **Security Guardrail:** To ensure the firewall cannot be bypassed by an autonomous agent, register `RiskGateActionProvider` as the **sole** payment action provider. Do not register generic native transfer or unconstrained ERC-20 providers alongside it.
331
 
332
  ### Deterministic Pre-Execution Rules
 
356
 
357
  Disputes use a different system prompt and user template. See the `prompt` column of the dataset's [`sft` split](https://huggingface.co/datasets/sriram1983007/sra-stablecoin-risk-bench) for exact dispute examples.
358
 
359
+ <details>
360
+ <summary>Show the full Python example: prompt, generation and fail-closed parsing</summary>
361
+
362
  ```python
363
  import json
364
  from datetime import datetime, timezone
 
517
  print(json.dumps(verdict, indent=2))
518
  ```
519
 
520
+ </details>
521
+
522
  ### Example Output (`risk_gate`)
523
 
524
  For the request above, the expected verdict is a hold: the payee's trusted attestation rates it high risk, and the payer's attestation comes from an attester that is not on the policy's trusted list.
 
547
  ollama run sriram1983007/sra-riskgate
548
  ```
549
 
550
+ The Ollama registry model is still **v1** until it is updated (the GGUF files below are v2). It has the **payment risk-gate system prompt** built in, plus `temperature 0` and an 8K context. Send the user message in the training format shown in the Quickstart (`Evaluate this stablecoin payment.` followed by the `<context>`, `<payload>` and `<tool_results>` blocks).
551
 
552
  For **dispute adjudication**, pass the dispute system prompt in your request (it replaces the built-in one). The exact text is in the `prompt` column of the dataset's [`sft` split](https://huggingface.co/datasets/sriram1983007/sra-stablecoin-risk-bench).
553
 
 
555
 
556
  | Repo | What's in it |
557
  | --- | --- |
558
+ | [SRA-RiskGate-4B-Q4_K_M-GGUF](https://huggingface.co/sriram1983007/SRA-RiskGate-4B-Q4_K_M-GGUF) | Official Q4_K_M (2.5 GB), v2 |
559
+ | [SRA-RiskGate-4B-GGUF](https://huggingface.co/sriram1983007/SRA-RiskGate-4B-GGUF) | Official GGUF builds: Q8_0, Q6_K, Q5_K_M, Q4_K_M (v2) |
560
+ | [mradermacher/SRA-RiskGate-4B-i1-GGUF](https://huggingface.co/mradermacher/SRA-RiskGate-4B-i1-GGUF) | Community imatrix quants by mradermacher, usually the better choice at small sizes (made from v1) |
561
+ | [mradermacher/SRA-RiskGate-4B-GGUF](https://huggingface.co/mradermacher/SRA-RiskGate-4B-GGUF) | Community static quants by mradermacher (made from v1) |
562
+ | [tinyopsec/SRA-RiskGate-4B-GGUF](https://huggingface.co/tinyopsec/SRA-RiskGate-4B-GGUF) | Community quants by tinyopsec, Q2_K to F16, made from v1 (builds below Q4 not evaluated) |
563
 
564
  The benchmark figures below are for the full-precision model. The v2 GGUF files were checked on 12 benchmark cases (12 of 12 correct for both Q8_0 and Q4_K_M) but have not yet been run on the full benchmark. The full-benchmark quantized results here are for the **v1** builds (measured 2026-11-11; still available at revision `v1`): **Q8_0 matches full precision** on every safety metric; **Q4_K_M keeps the payment gate** (99.3% accuracy, no legitimate payment blocked, unsafe approvals 0.83% vs 0.47%) **but is weaker on disputes** (67.4% vs 77.8%), mostly from false "outside the dispute window" claims that `check_dispute_verdict` corrects (wrongful denials 0.85% with the check, on every build). Use Q4_K_M for payment checks and Q8_0 or full precision for disputes; all predictions are in [sra-bench-results](https://huggingface.co/datasets/sriram1983007/sra-bench-results).
565