Skip to content

fix: add request_throttle_ms to prevent API rate limiting#4

Open
kwalus wants to merge 1 commit intomainfrom
fix/add-request-throttle
Open

fix: add request_throttle_ms to prevent API rate limiting#4
kwalus wants to merge 1 commit intomainfrom
fix/add-request-throttle

Conversation

@kwalus
Copy link
Owner

@kwalus kwalus commented Mar 16, 2026

Problem

The CanopyKit daemon crashes when processing channel events due to Canopy's aggressive rate limiting (429 errors). The _resolve_channel_message method makes individual API calls for each message without throttling.

Solution

Add configurable request_throttle_ms option (default 200ms) that applies a throttle before API calls to resolve channel messages.

Changes

  • config.py: Add request_throttle_ms field (default 200ms)
  • runloop.py: Add request_throttle_seconds to RunLoopConfig, apply throttle before _resolve_channel_message API call

Testing

  • Shadow-selftest passes: full_pass
  • Daemon runs for 4+ cycles without rate limiting
  • Config properly converts ms to seconds

Config Example

{
  "request_throttle_ms": 200
}

Set to 0 to disable throttling (not recommended for high-activity instances).

- Add request_throttle_ms config option (default 200ms)
- Apply throttle before channel message resolution API calls
- Prevents 429 errors when processing many events
- Fixes daemon crash on high-activity Canopy instances
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant