Skip to content

Remove agent rate limiting and its env knobs#188

Merged
chloeilabs merged 1 commit into
mainfrom
chore/remove-rate-limits
Jun 16, 2026
Merged

Remove agent rate limiting and its env knobs#188
chloeilabs merged 1 commit into
mainfrom
chore/remove-rate-limits

Conversation

@chloeilabs

Copy link
Copy Markdown
Owner

What

Removes the agent rate-limiting subsystem entirely — the sliding-window request limit (60/min/user) and the per-client concurrency cap (4 in-flight) — rather than disabling it behind a flag.

Why

The goal was to drop the limits and keep the env surface minimal. Flipping the existing AGENT_RATE_LIMIT_ENABLED=false kill switch would add an env var; deleting the feature lets us remove AGENT_RATE_LIMIT_ENABLED and AGENT_RATE_LIMIT_STORE instead.

Changes

Code

  • Delete src/lib/server/rate-limit.ts (sliding window + concurrency, memory/postgres stores).
  • Drop enforcement from /api/agent and /api/agent/follow-ups — no more 429 AGENT_RATE_LIMITED / *_CONCURRENCY_LIMITED paths.
  • agent-runtime-config.ts: remove the rate-limit/concurrency constants and the AGENT_RATE_LIMIT_ENABLED / AGENT_RATE_LIMIT_STORE env knobs (plus the now-unused env-parse helpers).
  • agent-route.ts: remove the rate-limit decision type, X-RateLimit-* / Retry-After headers, and the now-dead onStreamSettled settle machinery (its only caller was the concurrency-slot release).

Storage

  • app-migrate.mjs now drops the agent_rate_limit table (following the existing legacy-table cleanup pattern) instead of creating it. The table holds only transient counters, so dropping it is safe.

Tests & docs

  • Remove the rate-limit test + stub and the rate-limit assertions in the route/helper/http-error tests.
  • Update README.md, .env.example, and CLAUDE.md (no AGENT_RATE_LIMIT_* env vars).

Net: +40 / −1192 across 17 files.

Out of scope (intentionally kept)

src/lib/server/auth.ts still has Better Auth's credential-route limiter (rateLimit: { enabled: true }) — sign-in/sign-up brute-force protection (~100 req/10 s global; 5 req/15 min on credential routes). That's a distinct, security-sensitive control on the auth endpoints, not the agent throttling. Say the word if you want it removed too.

Verification

  • pnpm lint (--max-warnings=0), pnpm format:check, pnpm typecheck, pnpm test150/150 all pass.
  • pnpm app:migrate against the local DB drops agent_rate_limit (verified before/after).
  • Dev app compiles: POST /api/agent returns 401 unauthenticated, home redirects to /sign-in.

🤖 Generated with Claude Code

Removes the agent rate-limiting subsystem entirely (request limits + the
per-client concurrency cap) rather than disabling it via a flag, so the
env surface shrinks instead of growing.

Code:
- Delete src/lib/server/rate-limit.ts (sliding window + concurrency,
  memory/postgres stores).
- Drop enforcement from /api/agent and /api/agent/follow-ups (no more 429
  AGENT_RATE_LIMITED / CONCURRENCY_LIMITED paths).
- agent-runtime-config.ts: remove the rate-limit/concurrency constants and
  the AGENT_RATE_LIMIT_ENABLED / AGENT_RATE_LIMIT_STORE env knobs (and the
  now-unused env parse helpers).
- agent-route.ts: remove the rate-limit decision type, X-RateLimit/Retry-After
  headers, and the onStreamSettled settle machinery (its only caller was the
  concurrency-slot release).

Storage:
- app-migrate.mjs now drops the agent_rate_limit table (following the
  existing legacy-table cleanup pattern) instead of creating it.

Tests & docs:
- Remove rate-limit tests/stubs and the rate-limit assertions in the route,
  helper, and http-error tests.
- Update README, .env.example, and CLAUDE.md (no AGENT_RATE_LIMIT_* env vars).

Not touched: Better Auth's credential-route limiter in src/lib/server/auth.ts
(sign-in/sign-up brute-force protection) remains enabled — a separate,
security-sensitive control.

Verified: pnpm lint, format:check, typecheck, and test (150/150) pass;
pnpm app:migrate drops the table on the local DB; the dev app compiles
(/api/agent returns 401 unauthenticated, home redirects to sign-in).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chloei Ready Ready Preview, Comment Jun 16, 2026 5:12am

@chloeilabs chloeilabs merged commit 260681e into main Jun 16, 2026
6 checks passed
@chloeilabs chloeilabs deleted the chore/remove-rate-limits branch June 16, 2026 05:14
@chloeilabs chloeilabs mentioned this pull request Jun 16, 2026
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