Skip to content

[open-swe] feat: Add Supabase-backed rate limiting to auth middleware #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

open-swe[bot]
Copy link
Contributor

@open-swe open-swe bot commented Jun 23, 2025

Fixes #297

Implements a minimalistic rate limiting system for the Open SWE agent using Supabase as the backend storage.

Key Features:

  • Rate limits non-studio users to 15 requests for threads:create and threads:create_run events
  • Uses user.identity to track request counts in Supabase database
  • Exempts studio users and configurable list of users (via RATE_LIMIT_EXEMPT_USERS)
  • Returns "out of free credits" error message when limit exceeded

Implementation:

  • Added TypeScript interface for rate limiting table structure
  • Created Supabase client utility with environment variable configuration
  • Implemented rate limiting functions with proper error handling
  • Modified auth middleware event handlers to include rate limiting checks
  • Added environment variable placeholders to .env.example

Database Requirements:
A rate_limits table needs to be created in Supabase with columns matching the RateLimitRecord interface (user_identity, request_count, created_at, updated_at).

@open-swe open-swe bot added the open-swe label Jun 23, 2025
Copy link

vercel bot commented Jun 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
open-swe-web ❌ Failed (Inspect) Jun 23, 2025 7:03pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New Open SWE Request
0 participants