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-03-20
Stars
★ 4
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

micsapp
micsapp/micstec-skills

azure-apim-architecture

Analyzes and explains Azure API Management architecture decisions for enterprise API marketplace implementations using VNet Internal mode, Front Door, hybrid authentication, and multi-environment strategies. Use when discussing APIM component selection, network topology, cost optimization, or comparing alternatives like workspaces vs instances, VNet Internal vs External mode, or Front Door vs Application Gateway.

★ 4
micsapp
micsapp/micstec-skills

apiops-deployment

Guides deployment of Azure API Management infrastructure using Infrastructure as Code (Bicep/Terraform), CI/CD pipelines (GitHub Actions/Azure DevOps), and APIOps workflows. Use when deploying APIM, creating pipelines, or implementing dev→test→prod promotion strategies.

★ 4
micsapp
micsapp/micstec-skills

apim-policy-authoring

Creates production-ready Azure API Management policy XML for authentication (OAuth 2.0, JWT validation, subscription keys), rate limiting, CORS configuration, error handling, and API transformations. Use when implementing API security, access control, or request/response processing logic.

★ 4
micsapp
micsapp/micstec-skills

api-security-review

Reviews Azure API Management configurations for security vulnerabilities, OWASP API Security Top 10 compliance, VNet Internal mode validation, Private Link verification, and Azure Security Benchmark alignment. Use when performing security audits, pre-deployment validation, or compliance reviews.

★ 4
micsapp
micsapp/micstec-skills

jira-cli

Interact with Jira from the command line to create, list, view, edit, and transition issues, manage sprints and epics, and perform common Jira workflows. Use when the user asks about Jira tasks, tickets, issues, sprints, or needs to manage project work items.

★ 4
micsapp
micsapp/micstec-skills

calculator

Performs arbitrary-precision arithmetic calculations including addition, subtraction, multiplication, division, and exponents. Use when the user asks to calculate, compute, or evaluate math expressions, or when precise decimal arithmetic is needed to avoid floating-point errors.

★ 4