Skip to main content

RateLimitPolicyProtocol

Defined in the protocols module.
AI Agent Protocol for gateway rate-limit / throttle admission decisions. Pure, import-free decision contract consumed by the wrapper’s admission paths. The wrapper supplies typed facts (the caller identity, the scope — an endpoint class, channel, or tenant token — and the current now timestamp) and the policy decides whether the request is allowed or limited with a retry_after_seconds hint. Concrete state and enforcement (sliding windows, token buckets, a Redis-backed per-tenant quota) live in the implementation; this contract keeps the decision injectable and testable in isolation, symmetric with :class:SendPolicyProtocol / :class:GatewayConcurrencyPolicyProtocol. A config-driven default (:class:SlidingWindowRateLimitPolicy) is provided for the common “N requests per window per identity” case; core maps a limited decision onto ConnectErrorCode.RATE_LIMITED and HelloError.retry_after_seconds.

Methods

check()

Return a :class:RateLimitDecision for the supplied facts.

Source

View on GitHub

praisonaiagents/gateway/protocols.py at line 3619