Observed since 20 Oct, 23:16 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Safeguards for custom agents.
A comprehensive framework for implementing safety measures in multi-agent systems, focusing on budget coordination, monitoring, and guardrails.
The Safeguards framework provides tools and infrastructure for ensuring safe and controlled operation of AI agent systems. It addresses key challenges in multi-agent environments:
This framework is ideal for organizations deploying multiple AI agents that need to:
Budget Coordination System
Advanced Metrics Analysis
Safety Rules System
API Contracts
pip install agent-safeguards
from decimal import Decimal
from safeguards.core.budget_coordination import BudgetCoordinator
from safeguards.core.notification_manager import NotificationManager
from safeguards.api import APIFactory, APIVersion
from safeguards.types.agent import Agent
# Create core components
notification_manager = NotificationManager()
budget_coordinator = BudgetCoordinator(notification_manager)
api_factory = APIFactory()
# Create APIs
budget_api = api_factory.create_budget_api(APIVersion.V1, budget_coordinator)
agent_api = api_factory.create_agent_api(APIVersion.V1, budget_coordinator)
# Create a budget pool
pool = budget_api.create_budget_pool(
name="main_pool",
initial_budget=Decimal("100.0"),
priority=5
)
# Create an agent
agent = agent_api.create_agent(
name="example_agent",
initial_budget=Decimal("10.0"),
priority=3
)
# Check agent budget
budget = budget_api.get_budget(agent.id)
print(f"Agent {agent.name} has budget: {budget}")
from decimal import Decimal
from typing import Dict, Any
from safeguards.types.agent import Agent
class MyAgent(Agent):
def __init__(self, name: str, cost_per_action: Decimal = Decimal("0.1")):
super().__init__(name)
self.cost_per_action = cost_per_action
self.action_count = 0
def run(self, **kwargs: Any) -> Dict[str, Any]:
"""Execute agent logic with cost tracking."""
self.action_count += 1
# Your agent implementation here
return {
"result": "Task completed",
"action_count": self.action_count,
"cost": self.cost_per_action,
}
# Create and register agent
my_agent = MyAgent("custom_agent")
registered_agent = agent_api.create_agent(
name=my_agent.name,
initial_budget=Decimal("20.0"),
priority=5
)
# Run agent and update budget
for _ in range(3):
result = my_agent.run(input="Example task")
current_budget = budget_api.get_budget(registered_agent.id)
budget_api.update_budget(
registered_agent.id,
current_budget - result["cost"]
)
For more detailed examples, see the Quick Start Guide.
For a complete documentation index, see the Documentation README.
The Safeguards framework is designed for a variety of use cases:
# Clone the repository
git clone https://github.com/cirbuk/agent-safeguards.git
cd agent-safeguards
# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install development dependencies
pip install -r requirements-dev.txt
# Install package in development mode
pip install -e .
pytest tests/
The project uses:
Run formatters:
black .
isort .
Run type checking:
mypy src/
Run linters:
flake8 src/
pylint src/
Contributions are welcome! Please see our Contributing Guide for details on how to contribute to the project.
This framework implements several security measures:
If you discover a security vulnerability, please report it to dev@getmason.io.
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please open an issue on the GitHub repository or contact the Mason team at dev@getmason.io
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.3 | 23 Apr 2025 | 36 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 23:16 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:79daff122c08fc4dfe8899a9e689a2eb6c67825c461fb1c08cdafbfc0d4fddab