 Songhaoz666andClaude Opus 4.8
|
e4a120b715
|
/metrics 暴露 run 级 cost_by_phase{initial,review_retry}(Refs #16 #37)
回应 @Mem0ried 在 PR #37 的对接问题:除逐条 budget.alert 事件的 cost_phase 外,详情
聚合也需能拆 initial/review_retry。build_runtime_metrics 新增 cost_by_phase 滚动汇总
(按 swarm_id,从各任务 usage.model_cost_usd/model_tokens 按 rework_attributions 归类),
GET …/{id}/metrics 返回 {initial,review_retry}:{cost_usd,model_tokens}。HM 详情聚合 /
客户端 08 用量抽屉可直接展示拆分,无需从事件推导。
测试 test-usage-cost-phase.py 增 /metrics 断言(reworked→review_retry、非 reworked→initial);
usage-billing §5 记录该字段。
Refs #16
Refs #37
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
2026-06-11 14:36:07 +08:00 |
|
 Songhaoz666andClaude Opus 4.8
|
56e080bfa1
|
用量按 review-retry 成本归属:usage 事件标 cost_phase(Refs #16)
emit_usage_event 给每条 budget.alert 用量事件加 cost_phase:任务进入
run.metadata["rework_attributions"](cross-review 已 reopen)后的再执行标 review_retry,
否则 initial;并带 attempt(retry_count)。初次执行先于任何 attribution → initial,redo 在
run_cross_review 记录 attribution 之后 → review_retry,时序天然正确。计费/采集侧按 swarm_id
聚合时可用 cost_phase 拆分 initial vs review_retry 成本,满足「review retry 成本可归属」。
usage-billing-schema §4.2/§5/§6 同步:payload 加 cost_phase/attempt,§5 改为已打标,§6 缺口表
review_retry 标 ✅。测试 scripts/test-usage-cost-phase.py 接入 CI。
影响范围:仅 agent_swarm(usage 事件加字段 + 文档 + 测试);向后兼容;不改鉴权/契约/审批链/密钥。
Refs #16
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
2026-06-11 09:44:36 +08:00 |
|