Skip to content

Add rate limiting to KOI Coordinator #6

@DarrenZal

Description

@DarrenZal

Background

On Jan 9-10, 2026, the KOI pipeline experienced 57,116 false "content changed" events in 24 hours due to a bug in the GitHub sensor (fixed in regen-network/koi-sensors@b2b547e). This overwhelmed downstream services (BGE Server, OpenAI API) causing 429 rate limit errors.

Problem

The coordinator currently broadcasts all events immediately without any rate limiting. When a sensor malfunctions or a bulk re-index occurs, this can flood downstream services.

Proposed Solution

Add configurable rate limiting at the coordinator level:

# Example config
RATE_LIMIT_EVENTS_PER_MINUTE = 100
RATE_LIMIT_BURST = 50

Options to consider:

  1. Token bucket - Allow bursts but enforce average rate
  2. Sliding window - Hard limit per time window
  3. Per-source limits - Different limits per sensor type

Implementation Considerations

  • Should excess events be queued or dropped?
  • Should rate limits be per-source or global?
  • Need backpressure mechanism to slow down sensors?
  • Config via environment variables or config file?

Related

  • Event flood detection added in c3c0366
  • BGE Server retry logic added in 18b197c
  • Root cause (GitHub sensor RID bug) fixed in koi-sensors@b2b547e

Labels

enhancement, resilience

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions