The missing circuit breaker between your autonomous agents and your credit card. STOP letting runaway agent loops burn through your API budgets overnight.
Note: This is an independent private open-source project by Michael Ebering. Not affiliated with or endorsed by any employer.
ResGov is a lightweight, ultra-low-latency proxy and governance engine. It complements MCP and A2A by adding a strict economic layer: preventing cost explosions through real-time quota enforcement, per-agent budget tracking, and stream-safe cost governance.
π‘ Live Demo Β· Quick Start Β· Governance as Code Β· Architecture Β· API
Your agents make thousands of autonomous API calls. The moment they get stuck in a recursive loop while you sleep, they generate catastrophic API bills. Modern LLM providers offer billing alerts, but no real-time, granular execution-level budget enforcement.
- MCP (Model Context Protocol) β Defines how agents talk to tools.
- A2A (Agent-to-Agent) β Defines how agents delegate tasks.
- RGF (Resource Governance Framework) β Defines how agents spend your money.
ResGov is the industry's first open solution for the RGF layer.
- Transparent LLM Proxy: Drop-in replacement for OpenAI/Anthropic/OpenRouter endpoints. Just flip your framework's
base_url. - Atomic Pre-Commit & Finalize: Reserves a pessimistic
max_costduring a millisecond DB lock at stream start, streams lock-free, and refunds the difference instantly after stream-end. Zero deadlocks. - Governance as Code (
.rgf): Define limits, allowed models, and tools via a dead-simple configuration file straight inside your Git repo. - Non-LLM Resource Booking (
/api/v1/book): A unified control plane to throttle and audit paid web-scrapers, search APIs, or file operations. - Multi-Tenant Isolation: Real-world ready with organization-scoping and secure row-level data isolation.
- Predictive Budget Forecasting: Proactively avert cost overruns with AI-powered spend predictions.
Skip complex dashboard configurations for local or single-instance setups. ResGov lets you control budgets via a simple, declarative .rgf (TOML) file in your project root.
# .rgf - Resource Governance Rules
[global]
currency = "USD"
fail_safe_action = "deny" # Hard block if proxy connectivity drops
[agents.hermes]
daily_budget = 3.00
max_tokens_per_request = 4096
allowed_models = ["anthropic/claude-sonnet-4-6", "openrouter/deepseek/deepseek-v4-flash"]
[agents.research-bot]
daily_budget = 1.00
allowed_models = ["gpt-4o-mini"]
allowed_tools = ["web-scraper", "pexels_search"]ResGov utilizes historical spend patterns to predict when an agent is likely to exhaust its budget. This gives you time to intervene before an overrun occurs, enabling true proactive cost management.
Query the prediction API:
GET /api/v1/agents/my-agent-01/prediction?period=daily&lookback_hours=6Example Response:
{
"status": "ok",
"message": "Prediction successful.",
"remaining_budget": 42.15,
"rate_usd_per_hour": 1.75,
"prediction_timestamp": "2026-05-29T14:30:00Z",
"remaining_time_seconds": 86400.0
}git clone https://github.com/michael-ebering/resgov.git
cd resgov
cp .env.example .env # Set your RESGOV_ADMIN_TOKEN
docker compose up -d
# Core Proxy API: https://api.resgov.silentops.cloud/v1
# Dashboard: http://localhost:8080/dash
# Health V2: https://api.resgov.silentops.cloud/healthfrom crewai import Agent, LLM
llm = LLM(
model="openai/anthropic/claude-sonnet-4",
base_url="https://api.resgov.silentops.cloud/v1", # Routes through ResGov
api_key="your-rgf-api-key",
extra_headers={"X-ResGov-Agent-ID": "hermes"},
)
agent = Agent(role="Analyst", llm=llm, goal="Process streams...")from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="anthropic/claude-sonnet-4",
base_url="https://api.resgov.silentops.cloud/v1",
api_key="your-rgf-api-key",
default_headers={"X-ResGov-Agent-ID": "hermes"},
)When an agent attempts to breach its allocated .rgf budget, ResGov aborts the call immediately before it hits the upstream provider, returning a clean 403 Forbidden:
{
"error": {
"type": "budget_exceeded",
"message": "Daily budget exceeded. Limit: $3.00, Spent: $2.98, Required: $0.15",
"agent_id": "hermes",
"reason": "daily_budget_exceeded"
}
}For non-LLM transactional jobs (e.g., custom tool executions, paid data scraping):
# Book a Non-LLM resource allocation
POST /api/v1/book
{
"agent_id": "research-bot",
"resource_type": "api_call",
"action": "pexels_search",
"cost": 0.05,
"metadata": {"query": "infrastructure"}
}
# Admin Operations (Requires X-Admin-Token)
POST /api/v1/admin/reset-daily β Reset all daily allocations
POST /api/v1/admin/generate-key β Issue a new secure API Key
POST /api/v1/admin/price-cache/refresh β Refresh model price cache from OpenRouter
GET /api/v1/audit β Paginated system audit trail
GET /metrics β Native Prometheus metrics scraperflowchart TD
subgraph RGF["RGF Broker"]
direction LR
A["Auth Layer\nAPI Keys / Admin Token"]
B["Budget Engine"]
C["LLM Proxy\nReserve β Stream β Finalize"]
D["Webhooks\nDiscord / Slack / HMAC"]
E["Prometheus\n/metrics"]
B --> C
end
subgraph Storage["Storage\nSQLite WAL"]
F["resgov-db"]
end
B --> F
C --> F
- SQLite WAL Core: Leverages concurrent reads and serialized fast-writes. Perfect for zero-config single-instance environments and edge infrastructure.
- Pessimistic Stream Reservation: Solves concurrency double-spending by checking and deducting potential
max_costinstantly. The heavy streaming network phase runs completely lock-free. - Crash Recovery Guard: Stuck reservations automatically decay and revert after 5 minutes if an agent execution script crashes mid-stream.
Documentation:
- Interactive API Docs (Swagger) Β· ReDoc
- ONBOARDING.md β Developer quick-start guide
- DEPLOYMENT.md β Production deployment guide (Traefik, HTTPS, backups)
- docs/adr.md β Architecture Decision Records
- docs/rgf-examples.md β
.rgfconfiguration examples for 7 scenarios
- Redis/Dragonfly Backend for horizontal multi-instance proxy scaling.
- Out-of-the-box Slack & Discord alert layout engines.
- Predictive budget forecasting (spend-velocity heuristics).
- Open Policy Agent (OPA) declarative engine integration.
- Official Terraform Provider & Kubernetes Helm Charts.
- Multi-tenant Managed Cloud SaaS (resgov.silentops.cloud).
- Enterprise SSO / SAML & Granular Role-Based Access Control (RBAC).
This project is licensed under the Business Source License 1.1 (BSL-1.1).
- Free forever for personal use, testing, and internal non-commercial setups.
- Free forever for production scale in companies making < $1M ARR.
- Change Date: Automatically transitions into an open-source Apache 2.0 License on May 31, 2029.