context-mode
context-mode copied to clipboard
ctx_search rate limiter uses hand-rolled sliding window (drift-prone)
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.