Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

A spend gate for AI agents on metered data APIs: count, random sample, approved run, enforced by one Claude Code hook

说明与用途

AI 代理使用 Apify 计费 API 时的支出门控系统,通过三步流程:免费计数、可复现的随机抽样以及用户批准后再执行完整付费请求,避免意外费用。

问题

AI agents need a disciplined way to interact with metered data APIs so they do not incur unexpected costs.

结果

The spend‑gate prevented a costly full run by enforcing a free count, a reproducible random sample, and user approval before the paid run.

工作流

  • 1. Agent requests a count (mode=count) to get the total number of matching rows – free.
  • 2. Agent requests a random sample (mode=people, maxResults=100, sampleSeed set) to estimate data quality and cost – charged only for the sample.
  • 3. Agent requests the full run (mode=people, maxResults=desired) after approval – charged for the full set.
  • 4. A PreToolUse hook checks the tool name, mode, and maxResults; it blocks or allows the call based on the spend‑gate rules.

证据

The filter is the one from the job‑change part of the series: sales and revenue leaders at director level and above, employers of 50 to 5,000 people, US, UK and Germany, current role started in the last twelve months.

来源

The sample is the step the agent is allowed to pay for without asking. Its job is to turn the count into an expected delivery: of the 22,370, how many will arrive with a work email on record, how many with a personal one, what the employer sizes look like.

来源

A hook is a script that runs before the tool call, outside the model. It does not forget, and it does not read the data.

来源

The matcher is a regular expression because of the .*; a plain string would have to match the tool name exactly.

来源

  • 记录日期: 2026-10-14T09:41:12.315Z