context-mode icon indicating copy to clipboard operation
context-mode copied to clipboard

ctx_search rate limiter uses hand-rolled sliding window (drift-prone)

Open ofrik opened this issue 6 months ago • 0 comments

The ctx_search rate limiter uses a manual call counter with a 60-second reset timer. This is drift-prone: the window resets on a fixed interval from server start rather than sliding relative to each call, so burst patterns near the boundary can exceed the intended 8-call limit.

Suggested fix: Replace with a proper token bucket (e.g. a sliding window or leaky bucket algorithm). Libraries like bottleneck (Node) provide this out of the box.

Impact: Under adversarial or runaway agent conditions, the current implementation can allow more than 8 searches per 60-second window.

ofrik avatar May 23 '26 00:05 ofrik