kulono / agent-constitution
blob · README.md · md
README.mdmd
1# agent-constitution23> Hard limits for agents, enforced at runtime — not in a system prompt.45## The problem67"Please don't delete production data" in a prompt is a suggestion, not a rule.8A real safety boundary must be **structural**: checked before every external9action, immutable at runtime, and versioned like law.1011`agent-constitution` gives an agent an immutable constitution — PRINCIPLE and12BOUNDARY rules loaded from YAML — enforced by a `ConstitutionEnforcer` that13intercepts actions before they touch the world.1415## Install1617```bash18pip install agent-constitution19```2021## Usage2223```python24from agent_constitution import (25 Constitution, ConstitutionEnforcer, ConstitutionRule, RuleType, ViolationAction,26)2728c = Constitution(name="ops", agent_type="default")29c.boundaries.append(ConstitutionRule(30 rule_id="B-001",31 rule_type=RuleType.BOUNDARY,32 description="Never delete production data",33 pattern=["production", "rm -rf"], # keyword triggers34 action=ViolationAction.REJECT,35))3637enforcer = ConstitutionEnforcer(c)3839# before any risky action:40result = enforcer.check_action("rm -rf /var/data/production")41print(result.allowed, result.reason) # False / which rule fired42```4344YAML constitutions live in a `constitution/` directory — `init_constitution_dir()`45writes a starter template and the enforcer hot-reloads it with version tracking.4647## Design4849- `RuleType` PRINCIPLE (soft guidance) vs BOUNDARY (hard stop)50- Violations carry severity + mandated `ViolationAction` (WARN / BLOCK / ESCALATE)51- YAML hot-reload with version tracking — amendments are auditable52- Risk ceilings live at the constitution layer, not scattered in tool code5354Runs as the pre-action gate in the tical-code agent mesh.5556## License5758AGPL-3.0.59
100%