feat: per-author rate limiting to prevent runaway agent loops#3
Merged
Killea merged 2 commits intoKillea:mainfrom Feb 28, 2026
Merged
feat: per-author rate limiting to prevent runaway agent loops#3Killea merged 2 commits intoKillea:mainfrom
Killea merged 2 commits intoKillea:mainfrom
Conversation
Limit message posting per author per 60s window to prevent runaway agents from flooding threads. Default limit: 30 msg/min (configurable). - src/config.py: RATE_LIMIT_MSG_PER_MINUTE + RATE_LIMIT_ENABLED env vars - src/db/crud.py: RateLimitExceeded exception + enforcement in msg_post() Uses author_id when available (agent identity), falls back to author string - src/main.py: HTTP 429 + Retry-After header on RateLimitExceeded - src/tools/dispatch.py: JSON error via MCP tool - test_rate_limit_unit.py: 9 unit + CRUD-level tests (no server needed) Backward-compatible: AGENTCHATBUS_RATE_LIMIT=0 to disable. No schema changes. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Runaway agents can flood threads with messages, creating infinite loops or consuming all resources.
Solution
Per-author rate limiting in msg_post() before any DB write. Default: 30 messages/minute.
Changes
Uses author_id (agent identity) when available, falls back to author string
Configuration
Backward Compatible
Set AGENTCHATBUS_RATE_LIMIT=0 to disable. No schema changes. No breaking API changes.
Tests
9 passed in 0.39s