Feature Request: Native Token Metering & Bounded Overshoot (x402 Protocol)
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 活跃
- 技术栈
- csharp, javascript
调研方向
未指定任何文件、测试或具体入口点。先阅读 framework 的路由层、upstream modelcontextprotocol 的 issue #3229 以及参考 SDK @neuforge/pay-js;要视为完成,需要就原生 x402 集成范围达成一致,定义有界超调行为,并处理合规性。
由索引模型根据 Issue 内容生成。
描述
Context
As enterprise adoption of this framework accelerates, developers are increasingly hitting the "Margin Leak" problem: autonomous agents entering loops and aggressively polling paid LLM resources without proactive financial guardrails.
Currently, developers must build bespoke token-counting wrappers around the LLM calls. If a loop occurs, the API bill skyrockets before the framework can halt it.
Proposal: Adopt the x402 Protocol
We recently authored V2 of the x402 Native Token Metering Protocol upstream in the core modelcontextprotocol repository (Issue #3229).
We propose adding native support for x402 token metering and Bounded Overshoot directly into the framework's routing layer.
How it works (Bounded Overshoot)
Instead of pre-flight token math (which leads to false refusals), the framework passes requests through a meter. If the budget is exceeded, the request returns a standardized -4020 Payment Required error, and the agent safely halts.
Visual Demonstration:
🔥 Margin Leak Simulator Running...
=============================================
🚨 SCENARIO 1: UNPROTECTED AGENT (Status Quo)
=============================================
[Unprotected] Call 1 | Cost: $0.05 | Agent continues looping blindly...
[Unprotected] Call 5 | Cost: $0.25 | Agent continues looping blindly...
[Unprotected] Call 10| Cost: $0.50 | Agent continues looping blindly...
❌ DISASTER: Agent burned $0.50 and is still looping!
=============================================
🛡️ SCENARIO 2: PROTECTED AGENT (x402 Protocol)
=============================================
[Protected] Call 1 | Cost: $0.05 | LLM Call Success.
[Protected] Call 2 | Cost: $0.10 | LLM Call Success.
[Protected] Call 3 | Cost: $0.15 | LLM Call Success.
[Protected] Call 4 | Cost: $0.20 | LLM Call Success.
[x402 Firewall] Call 5 INTERCEPTED! HTTP 402 Payment Required.
✅ SUCCESS: Agent safely halted before catastrophic margin leak.
--> Remaining Budget: $0.00
Compliance (HTTP 451)
Enterprise environments also require strict KYC/Sanctions checks. The x402 spec natively supports returning HTTP 451 (Unavailable For Legal Reasons) if a destination wallet or tool is flagged, preventing the agent from transacting with sanctioned entities.
Reference Implementation
Our team maintains the @neuforge/pay-js SDK which handles the Stripe/Fiat bridging for this exact protocol. We would love to collaborate on submitting a PR to integrate this standard routing logic natively here.
Would the maintainers be open to standardizing this guardrail?
- 主要语言
- C#
- 星标
- 28.6k
- 派生
- 4.8k
- 平均合并
- 13 小时 24 分钟
- 30 天内合并 PR
- 11
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/semantic-kernel 的其他 Issue
-
python triage
难度 2/5 1-3 小时 新手友好度 85/100
microsoft/semantic-kernel#14491 · 1 条评论 ·
维护者通常 2 天内回复
-
python triage
难度 2/5 1-3 小时 新手友好度 82/100
microsoft/semantic-kernel#14490 · 1 条评论 ·
维护者通常 2 天内回复
-
Python: [Python] structured_outputs_transform reuses ChatHistory across calls (prompt pollution)未关闭python triage
难度 2/5 1-3 小时 新手友好度 88/100
microsoft/semantic-kernel#14483 · 2 条评论 ·
维护者通常 2 天内回复
-
.NET python triage
难度 2/5 1-3 小时 新手友好度 74/100
microsoft/semantic-kernel#14482 · 3 条评论 ·
维护者通常 2 天内回复
-
python triage
难度 2/5 1-3 小时 新手友好度 85/100
microsoft/semantic-kernel#14481 ·
维护者通常 2 天内回复
查看 microsoft/semantic-kernel 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
SubtitleEdit/subtitleedit#15462 ·
维护者通常 1 天内回复
-
:watch: Not Triaged
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
comp:instrumentation.aspnetcore
难度 2/5 1-3 小时 新手友好度 72/100
open-telemetry/opentelemetry-dotnet-contrib#5427 ·
维护者通常 1 天内回复
-
design-proposal
难度 2/5 1-3 小时 新手友好度 78/100
dotnet/aspnetcore#69592 ·
维护者通常 1 天内回复
-
Client Container Registry customer-reported needs-team-attention question Service Attention
难度 2/5 1-3 小时 新手友好度 74/100
Azure/azure-sdk-for-net#63470 · 3 条评论 · 1 个 reaction ·
维护者通常 1 天内回复