TTokenCoppice
Product

Product features · Token bucket admission

01

Bring arrival timestamps and request costs into the same project discussion so capped refill and admission use one explicit state transition.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Token bucket admission

● ● ●TokenCoppice●
A concrete starting point · Token bucket admission ×
from math import isfinite
def admit(tokens, last, now, capacity, rate, cost):
    values = (tokens, last, now, capacity, rate, cost)
    if not all(type(x) in (int, float) and isfinite(x) for x in values):
        raise ValueError("finite numbers required")
    if not (capacity > 0 and rate > 0 and 0 < cost <= capacity
            and 0 <= tokens <= capacity and now >= last):
        raise ValueError("invalid bucket state")
    refill = min(capacity, tokens + (now - last) * rate)
    allowed = refill >= cost
    return (refill - cost if allowed else refill, now), allowed
✳Decide token-bucket admission from an explicit timestamp and return the next state.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗