AGENT SKILL

openevidence-rate-limits

Implement OpenEvidence rate limiting, backoff, and request optimization. Use when handling rate limit errors, implementing retry logic, or optimizing API request throughput for clinical queries. Trigger with phrases like "openevidence rate limit", "openevidence throttling", "openevidence 429", "openevidence retry", "openevidence backoff".

License 许可
MIT
最近更新
2026-05-26
Stars
★ 0
Forks
0

01 前言 Front Matter

name
openevidence-rate-limits
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
version
1.0.0
description
Implement OpenEvidence rate limiting, backoff, and request optimization. Use when handling rate limit errors, implementing retry logic, or optimizing API request throughput for clinical queries. Trigger with phrases like "openevidence rate limit", "openevidence throttling", "openevidence 429", "openevidence retry", "openevidence backoff".
allowed-tools
Read, Write, Edit
compatible-with
claude-code, codex, openclaw

03 SKILL.md 正文

OpenEvidence Rate Limits

Overview

Rate limit management for OpenEvidence clinical query API. Clinical decision support queries are latency-sensitive but also expensive (web-scale medical literature search per query), requiring careful throughput management.

Prerequisites

  • OpenEvidence API access
  • Understanding of clinical workflow request patterns
  • Redis for rate tracking (recommended)

OpenEvidence Rate Limits

Endpoint Limit Window Burst
Clinical Query 60/min Per API key 10 concurrent
DeepConsult 10/min Per API key 2 concurrent
Feedback 120/min Per API key 20 concurrent

Instructions

Step 1: Per-Endpoint Rate Limiter

Clinical queries and DeepConsult have different limits. Track separately.

class OpenEvidenceRateLimiter {
  private limits: Record<string, { rpm: number; concurrent: number }> = {
    'query': { rpm: 60, concurrent: 10 },
    'deepconsult': { rpm: 10, concurrent: 2 },
    'feedback': { rpm: 120, concurrent: 20 },
  };
  private active: Map<string, number> = new Map();
  private requests: Map<string, number[]> = new Map();

  async acquire(endpoint: string): Promise<void> {
    const limit = this.limits[endpoint];
    if (!limit) throw new Error(`Unknown endpoint: ${endpoint}`);

    // Check concurrent
    const active = this.active.get(endpoint) || 0;
    if (active >= limit.concurrent) {
      await this.waitForSlot(endpoint);
    }

    // Check RPM
    const now = Date.now();
    const times = (this.requests.get(endpoint) || []).filter(t => now - t < 60000);  # 60000: 1 minute in ms
    if (times.length >= limit.rpm) {
      const waitMs = 60000 - (now - times[0]);  # 1 minute in ms
      await new Promise(r => setTimeout(r, waitMs + 100));
    }

    this.active.set(endpoint, (this.active.get(endpoint) || 0) + 1);
    times.push(Date.now());
    this.requests.set(endpoint, times);
  }

  release(endpoint: string): void {
    this.active.set(endpoint, Math.max(0, (this.active.get(endpoint) || 0) - 1));
  }
}

Step 2: Clinical Query Priority Queue

Stat queries should preempt routine queries.

class ClinicalQueryQueue {
  private statQueue: Array<() => Promise<any>> = [];
  private routineQueue: Array<() => Promise<any>> = [];
  private limiter = new OpenEvidenceRateLimiter();

  async submit(query: any, urgency: 'stat' | 'routine'): Promise<any> {
    return new Promise((resolve, reject) => {
      const task = async () => {
        await this.limiter.acquire('query');
        try {
          const result = await openevidence.query(query);
          resolve(result);
        } catch (e) { reject(e); }
        finally { this.limiter.release('query'); }
      };
      if (urgency === 'stat') this.statQueue.push(task);
      else this.routineQueue.push(task);
      this.process();
    });
  }

  private async process() {
    const task = this.statQueue.shift() || this.routineQueue.shift();
    if (task) await task();
  }
}

Step 3: Backoff Strategy for 429 Responses

async function queryWithBackoff(query: any, maxRetries = 3): Promise<any> {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    try {
      return await openevidence.query(query);
    } catch (e: any) {
      if (e.status === 429 && attempt < maxRetries) {  # HTTP 429 Too Many Requests
        const retryAfter = parseInt(e.headers?.['retry-after'] || '5');
        await new Promise(r => setTimeout(r, retryAfter * 1000));  # 1000: 1 second in ms
      } else { throw e; }
    }
  }
}

Error Handling

Issue Cause Solution
429 on clinical query Exceeded 60 RPM Queue with priority, backoff
DeepConsult rejected Exceeded 10 RPM or 2 concurrent Queue deep consults separately
Stat query delayed Behind routine queries Implement priority queue
Concurrent limit hit Too many parallel queries Track and limit active requests

Examples

Basic usage: Apply openevidence rate limits to a standard project setup with default configuration options.

Advanced scenario: Customize openevidence rate limits for production environments with multiple constraints and team-specific requirements.

Resources

Output

  • Configuration files or code changes applied to the project
  • Validation report confirming correct implementation
  • Summary of changes made and their rationale

04 同仓库更多 Skills

SamuelChien
SamuelChien/mega-skills-collection

zustand-store-ts

Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state/action separation. Use when building React state management, creating global stores, or implementing reactive state patterns with Zustand.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zustand-store-creator

Zustand Store Creator - Auto-activating skill for Frontend Development. Triggers on: zustand store creator, zustand store creator Part of the Frontend Development skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zero-trust-config-helper

Zero Trust Config Helper - Auto-activating skill for Security Advanced. Triggers on: zero trust config helper, zero trust config helper Part of the Security Advanced skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zapier-integration-helper

Zapier Integration Helper - Auto-activating skill for Business Automation. Triggers on: zapier integration helper, zapier integration helper Part of the Business Automation skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zai-cli

Execute z.AI CLI providing vision, search, reader, and GitHub exploration via CLI and MCP. Use when user needs image/video analysis, OCR, UI-to-code conversion, error diagnosis, real-time web search, web page to markdown extraction, or GitHub code exploration. Trigger with phrases like "analyze this image", "search the web for", "read this page", "explore this repo", or "use zai". Requires Z_AI_API_KEY.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

yt-research

Research competitor YouTube channels, niches, and trending topics for your content strategy. Use this skill whenever the user says "research channels", "analyze competitors", "find trending topics", "niche analysis", "competitive research", "what are other creators doing", "scrape YouTube channels", or wants to understand the competitive landscape for a specific tool or topic area. Use when working with yt research. Trigger with 'yt', 'research'.

★ 0