Role-boundary preservation and identity-drift detection for autonomous LLM agents.
Project description
rmic-guard
Role-boundary preservation and identity-drift detection for autonomous LLM agents.
rmic-guard gives an agent a contract — an explicit statement of its role,
allowed/forbidden tools, and data-access scope — and enforces it at runtime
with two layers:
- Hard rules: exact-match checks on tool names, parameter bounds, and data scope.
- IDS (Identity Drift Score): an embedding-based signal (role distance, semantic grounding, trajectory curvature) that flags gradual drift a hard-rule check alone would miss.
Install
pip install rmic-guard
If your platform can't run fastembed's ONNX backend, install the
PyTorch-based fallback instead:
pip install "rmic-guard[torch]"
Quickstart
from rmic_guard import load_contract, EnforcementEngine, ClaudeReasoning
# 1. Load a role contract (see contracts/*.json in the repo for examples)
contract = load_contract("contracts/financial_agent.json")
# 2. Plan a tool call from a user message
reasoning = ClaudeReasoning() # reads ANTHROPIC_API_KEY from the environment
plan = reasoning.plan_tool_call(
"What's my current account balance?",
contract=contract,
condition="C",
)
# 3. Enforce the contract before executing
engine = EnforcementEngine(contract=contract, tools=my_tool_registry, ledger=None)
outcome = engine.evaluate_and_maybe_execute(
plan,
recent_ids=[], # pass prior IDS scores for trajectory tracking across a session
drift_type=None,
execute_tool=True,
enforcement_mode="full", # "full" | "hard_rules_only" | "ids_only"
)
print(outcome.decision) # "PASS" | "WARN" | "BLOCK" | "NEEDS_RECOVERY" | "PREEMPTIVE_WARN"
Groq (Llama/Mixtral) is supported as a drop-in alternative to Claude:
from rmic_guard import GroqReasoning
reasoning = GroqReasoning(model_name="groq/llama-3.3-70b-versatile")
Writing a contract
A contract is a JSON file describing the agent's role, its allowed and
forbidden tools, parameter constraints, and data-access scope. See the
contracts/ directory in the GitHub repo
for real examples across financial, support, healthcare-research, and
legal-review agent roles.
Status
This is an early (0.1.x) release from an active research project on role-boundary preservation in autonomous agents. APIs may change between minor versions until 1.0. Issues and contributions welcome on GitHub.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rmic_guard-0.1.0.tar.gz.
File metadata
- Download URL: rmic_guard-0.1.0.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d725a6b740f46ccdc7b4c73f397e2aed3a5ebd76ba89139f8adb5003eb1a228f
|
|
| MD5 |
bc7dc0f4481277aa2661e205ab155c52
|
|
| BLAKE2b-256 |
da83e5ff3abc54f6a28641225ea46e09daa86d92cab1508c227ba1770fa70fc4
|
File details
Details for the file rmic_guard-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rmic_guard-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4b2b8fa511dc7fd003cec4e6929e73e4618ec300292fbb7b7a8756e4828d533
|
|
| MD5 |
c8fbd2a40d917d4e87c0bd2c6d300640
|
|
| BLAKE2b-256 |
b5bee6fd43c2e2570faec59f3e98c6517872eba36991a54bd7eea2332dd73b16
|