计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
serpapi-rate-limits【效率与协作】Discover SerpAPI account throughput and allowance dynamically, then enforce admission, concurrency, and retry budgets. Use when preventing 429s or coordinating search workers. Trigger with "configure SerpAPI rate limits".
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use the account's live contract as the source of truth instead of embedding plan names or numeric limits in code.
Use Read, Glob, and Grep to inventory producers and retry loops, WebFetch to verify current Account API and status semantics, Write or Edit for admission controls and observability, and Bash(python3:*) for an approved capacity check or load simulation.
Account API returns fields including plan_searches_left, total_searches_left, this_hour_searches, and account_rate_limit_per_hour. HTTP 429 can mean the hourly throughput limit was exceeded or the account ran out of searches, so the response alone does not identify the remedy.
Use a server-side SERPAPI_KEY for Account API and search calls. Centralize capacity across every workload sharing that credential; do not expose account fields or the key through a public health endpoint.
Return the producer inventory, live capacity snapshot, admission and concurrency budgets, 429 decision tree, retry policy, test evidence, alerts, and rollback owner.
| Condition | Response |
|---|---|
| Account API unavailable | Fail closed to a conservative cached budget with an expiry. |
| Throughput exhausted | Pause and drain; do not amplify with immediate retries. |
| Searches exhausted | Stop allowance-consuming work and route to the account owner. |
| Multiple uncoordinated workers | Introduce a shared limiter before increasing parallelism. |
account = client.account()
hourly_limit = int(account["account_rate_limit_per_hour"])
used_this_hour = int(account["this_hour_searches"])
headroom = max(0, hourly_limit - used_this_hour)
admission_budget = max(0, int(headroom * 0.8)) # reserve 20% for priority traffic
Review the live capacity at renewal and whenever a new worker or search product begins sharing the account.