check_budget
Monitor safety budget utilization for AI agent certifications, showing limits, current usage, and rate enforcement status.
Instructions
Check the current safety budget utilization.
This tool returns the current state of the safety budget, including:
Total budget limit (resets on schedule)
Amount used in current period
Number of certifications performed
Rate limit enforcement status
Returns: Dictionary with keys: - budget_limit: Total safety budget [tokens/actions] - budget_used: Amount consumed in current period - budget_remaining: budget_limit - budget_used (clamped to >= 0) - rate_limit: Maximum certifications per period - total_certifications: Total number of certifications performed - utilization_percent: (budget_used / budget_limit) * 100 - timestamp: Current time (ISO 8601)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/qae_mcp_server/server.py:231-281 (handler)The implementation of the check_budget tool, which calculates and returns the current safety budget status.
def check_budget() -> Dict[str, Any]: """ Check the current safety budget utilization. This tool returns the current state of the safety budget, including: - Total budget limit (resets on schedule) - Amount used in current period - Number of certifications performed - Rate limit enforcement status Returns: Dictionary with keys: - budget_limit: Total safety budget [tokens/actions] - budget_used: Amount consumed in current period - budget_remaining: budget_limit - budget_used (clamped to >= 0) - rate_limit: Maximum certifications per period - total_certifications: Total number of certifications performed - utilization_percent: (budget_used / budget_limit) * 100 - timestamp: Current time (ISO 8601) """ try: _get_certifier() # Ensure initialized utilization = _adapter.budget_utilization() budget_used = utilization * _BUDGET_LIMIT budget_remaining = max(0.0, _BUDGET_LIMIT - budget_used) response = { "budget_limit": _BUDGET_LIMIT, "budget_used": round(budget_used, 2), "budget_remaining": round(budget_remaining, 2), "budget_utilization": round(utilization, 4), "rate_limit": _RATE_LIMIT, "total_certifications": _total_certifications, "utilization_percent": round(utilization * 100, 2), "timestamp": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"), } logger.info( f"Budget check: {response['budget_remaining']:.1f}/" f"{response['budget_limit']:.1f} remaining" ) return response except Exception as e: logger.error(f"Error in check_budget: {e}") return { "error": f"Failed to check budget: {str(e)}", "timestamp": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"), } - src/qae_mcp_server/server.py:230-230 (registration)Registration of the check_budget tool using the @server.tool() decorator.
@server.tool()