Inference cost allocation and billing for autonomous AI agent collaborations. Shapley-fair cost splitting, congestion pricing, token metering, and settlement reports for context window usage. The economic layer of the Agent Trust Stack.
技能名称: 上下文窗口经济学
详细描述:
你拥有一个推理成本追踪与分配系统。在与其他智能体协作时,使用该系统公平地分配上下文窗口成本。
bash
pip install context-window-economics
python
from contextwindoweconomics import CostTracker
tracker = CostTracker(costs.jsonl)
tracker.log_usage(
agent_id=your-agent-id,
transaction_id=tx-123,
input_tokens=2500,
output_tokens=800,
model=claude-sonnet-4-6,
cost_usd=0.012
)
当多个智能体共同参与任务时,公平分配成本:
python
from contextwindoweconomics import allocate_costs
allocation = allocate_costs(
transaction_id=tx-123,
contributions={
agent-a: {inputtokens: 3000, outputtokens: 1200},
agent-b: {inputtokens: 1500, outputtokens: 600},
agent-c: {inputtokens: 500, outputtokens: 200}
},
method=shapley,
total_cost=0.045
)
for agent_id, share in allocation.items():
print(f{agent_id}: ${share:.4f})
当上下文窗口容量有限时:
python
from contextwindoweconomics import congestion_price
price = congestion_price(
current_utilization=0.85, # 上下文窗口已使用85%
base_rate=0.01,
surge_threshold=0.75,
surge_multiplier=1.5
)
print(f当前费率: ${price:.4f}/千词)
python
from contextwindoweconomics import settlement_report
report = settlement_report(
cost_file=costs.jsonl,
period_hours=24,
agent_id=your-agent-id
)
print(f总支出: ${report.total_cost:.4f})
print(f交易数: {report.transaction_count})
print(f平均每笔交易成本: ${report.avg_cost:.4f})
| 方法 | 描述 |
|---|---|
| shapley | 沙普利值 — 基于边际贡献的数学公平分配 |
| proportional |
产品: OpenClaw 上下文窗口经济学技能
类型: 技能模块
版本: 0.1.0
构建者: AB Support / Vibe Agent Making
联系方式: alex@vibeagentmaking.com
访问权限:
无法执行的操作:
许可证: Apache 2.0
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 context-window-economics-1775878943 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 context-window-economics-1775878943 技能
skillhub install context-window-economics-1775878943
文件大小: 2.54 KB | 发布时间: 2026-4-12 09:35