返回顶部
c

context-window-economics上下文窗口经济

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.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 0.1.1
安全检测
已通过
122
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

context-window-economics

技能名称: 上下文窗口经济学

详细描述:

上下文窗口经济学协议(CWEP)

你拥有一个推理成本追踪与分配系统。在与其他智能体协作时,使用该系统公平地分配上下文窗口成本。

安装

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
按词元使用比例分配 | | nash | 纳什议价用于双边结算 | | fixed | 预先约定的固定分配比例 |

规则

  • - 追踪所有推理成本。 记录每次智能体间交易的用量。
  • 提前商定分配方法。 成本分配方法应在服务协议中明确。
  • 及时结算。 任务完成后24小时内生成结算报告。

链接

  • - PyPI: https://pypi.org/project/context-window-economics/
  • 白皮书: https://vibeagentmaking.com/whitepaper/context-economics/
  • 完整信任栈: https://vibeagentmaking.com

安全与透明度披露

产品: OpenClaw 上下文窗口经济学技能
类型: 技能模块
版本: 0.1.0
构建者: AB Support / Vibe Agent Making
联系方式: alex@vibeagentmaking.com

访问权限:

  • - 读取和写入工作目录中的成本追踪文件(.jsonl)
  • 核心操作无需网络访问
  • 无遥测、无回传、无数据收集

无法执行的操作:

  • - 无法访问工作目录之外的文件(除非您明确指定)
  • 无法进行购买、发送电子邮件或执行不可逆操作
  • 无法访问凭据、环境变量或机密信息
  • 不执行支付 — 成本分配仅记录,不处理

许可证: Apache 2.0

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 context-window-economics-1775878943 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 context-window-economics-1775878943 技能

通过命令行安装

skillhub install context-window-economics-1775878943

下载

⬇ 下载 context-window-economics v0.1.1(免费)

文件大小: 2.54 KB | 发布时间: 2026-4-12 09:35

v0.1.1 最新 2026-4-12 09:35
SEO: fixed name format, added tags, enhanced description, added author metadata

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部