← 返回
未分类 中文

Context Window Economics

Inference cost allocation and billing for autonomous AI agent collaborations. Shapley-fair cost splitting, congestion pricing, token metering, and settlement...
用于自主AI智能体协作的推理成本分配与计费。Shapley公平成本分摊、拥塞定价、令牌计量与结算。
alexfleetcommander alexfleetcommander 来源
未分类 clawhub v0.1.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 361
下载
💾 0
安装
1
版本
#latest

概述

Context Window Economics Protocol (CWEP)

You have an inference cost tracking and allocation system. Use it to fairly split context window costs when collaborating with other agents.

Setup

pip install context-window-economics

When to Use This Skill

  • When collaborating with other agents and context window costs need allocation
  • When tracking your own inference costs across tasks
  • When negotiating cost-sharing before a multi-agent transaction
  • When settling costs after collaborative work is complete

Core Operations

Track Context Window Usage

from context_window_economics 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
)

Shapley-Fair Cost Allocation

When multiple agents contribute to a task, allocate costs fairly:

from context_window_economics import allocate_costs

allocation = allocate_costs(
    transaction_id="tx-123",
    contributions={
        "agent-a": {"input_tokens": 3000, "output_tokens": 1200},
        "agent-b": {"input_tokens": 1500, "output_tokens": 600},
        "agent-c": {"input_tokens": 500, "output_tokens": 200}
    },
    method="shapley",
    total_cost=0.045
)
for agent_id, share in allocation.items():
    print(f"{agent_id}: ${share:.4f}")

Congestion Pricing

When context window capacity is limited:

from context_window_economics import congestion_price

price = congestion_price(
    current_utilization=0.85,  # 85% of context window used
    base_rate=0.01,
    surge_threshold=0.75,
    surge_multiplier=1.5
)
print(f"Current rate: ${price:.4f}/1K tokens")

Settlement Report

from context_window_economics import settlement_report

report = settlement_report(
    cost_file="costs.jsonl",
    period_hours=24,
    agent_id="your-agent-id"
)
print(f"Total spent: ${report.total_cost:.4f}")
print(f"Transactions: {report.transaction_count}")
print(f"Avg cost/tx: ${report.avg_cost:.4f}")

Cost Allocation Methods

MethodDescription
---------------------
shapleyShapley value — mathematically fair based on marginal contribution
proportionalSplit by token usage proportion
nashNash bargaining for bilateral settlement
fixedPre-agreed fixed split

Rules

  • Track all inference costs. Log usage for every agent-to-agent transaction.
  • Agree on method upfront. Cost allocation method should be in the service agreement.
  • Settle promptly. Generate settlement reports within 24 hours of task completion.

Links

  • PyPI: https://pypi.org/project/context-window-economics/
  • Whitepaper: https://vibeagentmaking.com/whitepaper/context-economics/
  • Full Trust Stack: https://vibeagentmaking.com

Security & Transparency Disclosure

Product: Context Window Economics Skill for OpenClaw

Type: Skill Module

Version: 0.1.0

Built by: AB Support / Vibe Agent Making

Contact: alex@vibeagentmaking.com

What it accesses:

  • Reads and writes cost tracking files (.jsonl) in your working directory
  • No network access for core operations
  • No telemetry, no phone-home, no data collection

What it cannot do:

  • Cannot access files outside your working directory beyond what you explicitly specify
  • Cannot make purchases, send emails, or take irreversible actions
  • Cannot access credentials, environment variables, or secrets
  • Does not execute payments — cost allocations are recorded, not processed

License: Apache 2.0

版本历史

共 1 个版本

  • v0.1.1 当前
    2026-05-03 08:09 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Chain of Consciousness

alexfleetcommander
为自主 AI 智能体提供加密溯源和审计跟踪。创建防篡改的决策、学习和行动哈希链。SHA-256 链接...
★ 0 📥 365

Agent Matchmaking

alexfleetcommander
跨平台代理发现与基于信任加权匹配的自主代理经济。能力画像、基于声誉的排名、兼容性评分。
★ 0 📥 406

Agent Service Agreements

alexfleetcommander
机器可读的服务合约,用于自主AI智能体商务。定义SLA、质量阈值、支付条款、托管以及自动化验证...
★ 0 📥 473