Skip to content

[WIP] Add rate limiting and throttle layer functionality - #51

Merged
Piboonsak merged 3 commits into
mainfrom
copilot/feature-rate-limiting-throttle-layer
Apr 5, 2026
Merged

Piboonsak merged 3 commits into
mainfrom
copilot/feature-rate-limiting-throttle-layer

Conversation

Copilot AI commented Apr 5, 2026 •

Copy link
Copy Markdown
  • Create src/infra/rate-limiter.ts — sliding-window per-user and global rate limiter
  • Add RateLimitConfig type to src/config/types.openclaw.ts (new top-level rateLimit key)
  • Add Zod schema for rateLimit in src/config/zod-schema.ts
  • Create src/infra/rate-limiter.test.ts — 11 unit tests (all passing)
  • Fix: global window is now a single shared instance across all channels (API cost protection)
  • Fix: channel-specific global overrides use isolated per-channel windows
  • Fix: makeConfig helper now returns Pick<OpenClawConfig, 'rateLimit'> (correct type)
  • All tests passing (22 tests across 3 files)

Copilot AI linked an issue Apr 5, 2026 that may be closed by this pull request
- Add src/infra/rate-limiter.ts: sliding-window per-user and global
  rate limiter with channel-aware overrides and friendly rejection messages
- Add RateLimitConfig type and RateLimitChannelOverride type to
  src/config/types.openclaw.ts under top-level rateLimit key
- Add rateLimit Zod schema to src/config/zod-schema.ts
  (perUser, global, windowMs, channelOverrides)
- Add src/infra/rate-limiter.test.ts with 9 unit tests

Agent-Logs-Url: https://github.com/Piboonsak/openclaw_github/sessions/16e35128-14bb-4f00-adb6-d456d9622d94
@Piboonsak
Piboonsak marked this pull request as ready for review April 5, 2026 13:22
Per code review:
- Replace per-channel globalWindows map with single shared global window
  so the global quota truly guards API cost across all channels combined
- Channel-specific global overrides get their own isolated window via
  channelGlobalWindows map
- Fix makeConfig test helper return type to Pick<OpenClawConfig, 'rateLimit'>
- Add two new tests: cross-channel global sharing and per-channel override

Agent-Logs-Url: https://github.com/Piboonsak/openclaw_github/sessions/16e35128-14bb-4f00-adb6-d456d9622d94
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.

[Feature] Rate Limiting / Throttle Layer

2 participants