AI代理账单来了:2026年消耗式计费与任务预算实战

·阅读约15分钟·Evergreen Tools Team

💡 工具推荐管理代理预算时,用 Evergreen Tools 的 Token计算器 估算任务成本、JSON格式化 校验预算策略、Cron生成器 编排定时对账任务!

2026 年 5 月到 7 月,代理产品的计费模式集体转向:Microsoft Agent 365 于 5 月 1 日正式可用,Copilot Cowork 在 6 月 16 日全球上线并引入 Copilot Credits——按需付费每个 1 美分;ChatGPT Work 于 7 月 9 日发布,Claude Cowork 于 7 月 7 日覆盖 Web 与移动端。四款产品底层模式一致:席位之上按消耗计费。用席位预测成本的时代结束了,本文教你用预算中间件、硬上限与成本台账管理这笔新账单。

成本数据与账单

席位之上按消耗计费

一、2026 年的代理计费格局

微软的落地最典型:Microsoft 365 E7 与 Agent 365 都在 5 月 1 日达到正式可用,Agent 365 独立授权 $15/用户/月;Copilot Cowork 需要 Copilot 授权外加基于用量的 Copilot Credits,按需付费每个 1 美分,并支持租户、组、用户三级花费上限。Anthropic 推出任务预算(task budgets),让长时间运行的代理无法悄悄烧光额度;Cursor 按路由计费,Perplexity 对 Computer 使用计量。结论很直接:席位制预测已经无法描述代理成本。

二、先定义预算策略

代码示例1 是一份三层预算策略:租户、组、用户各有日/月上限,并配置软警告(80%)与硬停止(100%)阈值。这套结构与 Copilot Credits 的 spend limits 完全同构。关键设计决策是「谁负责预算」:FinOps 团队定义策略,工程团队只需要知道「我这个任务还剩多少额度」。把策略放进代码仓库,走 PR 评审,预算变更就变得可审计。

// budget-policy.json — spend limits at tenant, group, and user level
{
  "currency": "USD",
  "limits": {
    "tenant": { "daily": 5000, "monthly": 90000 },
    "group:eng": { "daily": 1500, "monthly": 30000 },
    "user:default": { "daily": 50, "monthly": 800 }
  },
  "actions": {
    "soft_warn_at": 0.8,   // warn at 80% of the limit
    "hard_stop_at": 1.0,   // block new agent runs at 100%
    "notify": ["[email protected]", "#ai-spend"]
  }
}
# The 2026 pattern is uniform: agents are billed by consumption on top
# of seats. Copilot Cowork requires Copilot Credits at one cent each on
# pay-as-you-go; Cursor bills routing; Perplexity meters Computer usage.

三、用中间件在花钱前拦截

预算纪律的核心是「先检查、后消费」,而不是事后对账。代码示例2 是一个 BudgetGuard 中间件:任务启动前,用已用额度加预估成本对比日/月上限,超限直接抛错。Anthropic 的任务预算、微软的 spend limits 底层都是这个形状。把它接进你的代理编排层,任何任务、任何模型都无法绕过。

// budget-middleware.ts — enforce a hard stop before a task starts
type Budget = { daily: number; monthly: number };

export class BudgetGuard {
  constructor(private used: (key: string) => number) {}

  async canRun(key: string, estimatedCost: number, budget: Budget) {
    const usedToday = this.used(`day:${key}`);
    const usedMonth = this.used(`month:${key}`);
    if (usedToday + estimatedCost > budget.daily) {
      throw new Error(`Daily budget exceeded for ${key}`);
    }
    if (usedMonth + estimatedCost > budget.monthly) {
      throw new Error(`Monthly budget exceeded for ${key}`);
    }
    return true;
  }
}

// Anthropic ships task budgets so a long-running agent cannot silently
// exhaust a quota. Microsoft enforces spend limits at tenant, group and
// user level. The same shape applies whether you run managed agents or
// your own orchestration: check before you spend, not after.

四、给每个代理运行加硬上限

中间件管策略,硬上限管单次运行。代码示例3 是一个包装脚本:给任何代理 CLI 加美元上限与墙钟超时,运行结束把结果写进台账。30 分钟超时 + $10 上限的组合,可以拦住绝大多数「代理失控」事故。记住:超时与超支是同一类问题——都在运行前设防,而不是运行后追责。

# agent-run.sh — wrap any agent CLI with a cost cap and a timer
#!/usr/bin/env bash
set -euo pipefail
TASK_ID="${1:?usage: agent-run.sh <task-id>}"
CAP_USD="${CAP_USD:-10}"            # hard dollar cap for this run
TIMEOUT_MIN="${TIMEOUT_MIN:-30}"    # hard wall-clock cap

echo "[agent-run] task=$TASK_ID cap=$CAP_USD timeout=${TIMEOUT_MIN}m"

# macOS 'timeout' alternative via perl alarm
perl -e 'alarm shift; exec @ARGV' "$((TIMEOUT_MIN*60))" \
  copilot-cli run "$TASK_ID" --max-budget-usd "$CAP_USD" \
  | tee ".agent-runs/$TASK_ID.log"

# Record the run for the FinOps ledger
echo "$(date -u +%FT%TZ)|$TASK_ID|$CAP_USD|$?" >> .agent-runs/ledger.tsv
# Seat-based forecasting no longer describes what agents cost.
# Meter every run, every model, every task — then budget from data.

五、用数据校准预算

预算不是拍脑袋。代码示例4 的 SQL 按团队与模型汇总月度花费,并给出 2026 年的参考价格锚点:Gemini 3.6 Flash $1.50/$7.50 每百万 token、Sonnet 5 促销期 $2/$10、Opus 5 $5/$25。当月均单次运行成本明显偏离这些锚点时,就该调查了——可能是路由配置失效,也可能是某个代理在循环调用。

# spend-report.sql — roll up agent spend by team and by model
SELECT
  team,
  model,
  COUNT(*)                       AS runs,
  ROUND(SUM(cost_usd), 2)        AS total_usd,
  ROUND(AVG(cost_usd), 4)        AS avg_usd_per_run
FROM agent_runs
WHERE started_at >= date_trunc('month', now())
GROUP BY team, model
ORDER BY total_usd DESC;

-- Key 2026 reference points for sanity-checking your numbers:
--   Agent 365 standalone licence: $15/user/month (GA May 1, 2026)
--   Copilot Credits: $0.01 each, pay-as-you-go
--   Gemini 3.6 Flash: $1.50/$7.50 per 1M tokens (July 21, 2026)
--   Claude Sonnet 5 intro: $2/$10 until Aug 31, then $3/$15
-- If your average run cost drifts far from these, investigate.

六、总结

2026 年,代理成本从「席位 × 单价」变成「席位 + 消耗」,账单的不确定性大幅上升。应对之道并不复杂:定义三层预算策略、用中间件在花钱前拦截、给单次运行加硬上限、用台账持续校准。这套体系能让你的代理支出可预测、可审计、可优化——账单来了,接住它就行。

财务与预算规划

先检查,后消费

📌 常见问题 FAQ

什么是消耗式计费(consumption billing)?

代理产品在席位费之外按实际用量计费:Copilot Cowork 的 Copilot Credits 每个 1 美分、Cursor 按路由计费、Perplexity 对 Computer 使用计量。成本随任务量浮动,不再固定。

Copilot Credits 是什么?

Copilot Cowork 的用量货币,按需付费每个 1 美分,支持租户、组、用户三级花费上限,可在 Azure/微软管理门户配置。

Anthropic 的任务预算怎么工作?

Anthropic 为长时间运行的代理提供任务预算(task budgets),防止代理静默耗尽额度。超预算时任务会被暂停或终止,而不是无限烧钱。

如何防止代理失控烧钱?

三层防线:预算策略(日/月上限)、预算中间件(花钱前拦截)、单次运行硬上限(美元 + 超时)。再加成本台账持续监控。

2026 年代理的参考价格是多少?

Agent 365 独立授权 $15/用户/月;Gemini 3.6 Flash $1.50/$7.50 每百万 token;Claude Sonnet 5 促销期 $2/$10(8 月 31 日后 $3/$15);Claude Opus 5 $5/$25。