Current collected state Current
Observed since 20 Oct, 22:04 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Embedded multi-tenant Agent governance engine - cost attribution, declarative policies, and audit
轻量级 Agent 治理与执行中间件 —— 成本控制、审计追踪、模型路由、DAG 编排、可观测性。
# 核心功能
pip install agent-governor
# 全部可选功能(DAG + OTel + MCP + HTTP)
pip install agent-governor[all]
# 按需选择
pip install agent-governor[dag] # DAG 编排(networkx)
pip install agent-governor[telemetry] # OTel Tracing + Metrics
pip install agent-governor[mcp] # MCP 工具执行器
pip install agent-governor[redis] # Redis 状态后端
from agent_governor import Governor
governor = Governor(
budget_usd=10.0,
models=["gpt-4o", "qwen-plus"],
fallback_model="qwen-turbo",
)
response = await governor.execute(
messages=[{"role": "user", "content": "Hello!"}],
model="gpt-4o",
)
from agent_governor import Governor
from agent_governor.control import TaskGraph, SchemaGate
governor = Governor(budget_usd=5.0)
graph = TaskGraph("research_report")
graph.add_node("search", task=Task(name="web_search", metadata={"query": "..."}))
graph.add_node("analyze", task=Task(name="analyze"), depends_on=["search"])
graph.add_node("validate", task=Task(name="validate"), depends_on=["analyze"],
quality_gates=[SchemaGate(ReportModel)])
result = await governor.run_graph(graph)
governor = Governor(
budget_usd=10.0,
tracing_enabled=True,
otlp_endpoint="http://localhost:4317",
)
# 使用 async context manager 确保资源释放
async with governor:
result = await governor.execute(messages=[...], model="gpt-4o")
mcp.ClientSession.call_tool()agent-governor-report 命令行工具# 查看最近 7 天的成本报告
agent-governor-report --file audit.jsonl --last 7d --group-by model
# JSON 格式输出
agent-governor-report --file audit.jsonl --format json
src/agent_governor/
├── governor.py # 主入口
├── config.py # GovernorConfig 配置模型
├── models.py # Task / TaskResult 数据模型
├── protocols.py # Executor / QualityGate 协议定义
├── exceptions.py # 异常体系
├── control/ # 控制层:DAG、质量门、状态管理
├── data/ # 数据层:调度、熔断、并发、执行器
├── observability/ # 可观测层:Tracing、Metrics、审计、成本
└── cli/ # 命令行工具
# 创建环境
uv venv --python 3.12
uv pip install -e ".[dev]"
# 运行测试
pytest tests/ -q
# 静态检查
ruff check src/ tests/
mypy src/
# 本地构建文档站
uv pip install -e ".[docs]"
mkdocs serve
MIT
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.4.0 | 29 Jul 2026 | 19 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 22:04 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:665135564ef110d35fac8c55d8c68c650f6a99b3d0f1225b4db5cb48c3e16acf