What the agent does
The agent reads app/auth/routes.py, app/__init__.py, config.py, requirements.txt, the auth/reset_password_request.html template and tests.py first. The app had no rate limiting, already pinned every dependency, and already had a Redis URL in Config.
It creates one Limiter in app/__init__.py and decorates reset_password_request with @limiter.limit('3 per hour', key_func=reset_request_key, methods=['POST'], on_breach=reset_request_limited). The key is the submitted email, trimmed and lowercased, with the client address only when no email is sent. On a breach it re-renders the reset form with a flash message and status 429. config.py gets RATELIMIT_STORAGE_URI, defaulting to memory://, and tests.py gets a PasswordResetRateLimitCase with three tests.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "A Linear issue labeled agent says: \"Rate Limit Password Reset in a Flask App. Allow at most 3 reset password requests per email per hour with Flask-Limiter and show a friendly message when the limit is hit.\" Do the work in this repository, add tests for it, run pytest, and open a pull request that links back to the issue.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
Tried on miguelgrinberg/microblog at a975ef6: 5 files changed, 78 insertions(+), 3 deletions(-) in app/__init__.py, app/auth/routes.py, config.py, requirements.txt and tests.py. pytest tests.py went from 4 passed in 2.08s on the untouched clone to 7 passed in 1.47s. The first test asserts that three POSTs return 302, the fourth 429 with too many password resets, and that only 3 mails were recorded. The Linear issue was the task text; the run had no issue id to link and opened no pull request.
For the reviewer: memory:// is per process, so with several gunicorn workers the real limit is higher; decide whether to default to the existing REDIS_URL. The new message is not in the Spanish translations, and uv resolved the three new pins, Flask-Limiter==4.1.1, limits==5.8.0 and ordered-set==4.1.0, so re-check them with pip.
Run it on every Linear issue labeled agent
An automation with a linear trigger on linear.issue.labeled and the label agent runs the linear-label-to-pr recipe's prompt when someone in your Rush org labels a security issue. An issue that names the limiter storage, such as the app's existing REDIS_URL, lets the agent use it instead of the per-process memory:// default.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
The first version of the new tests got 200 instead of 302: Flask-WTF's CSRF check rejected the test client's forms. The run found that, set WTF_CSRF_ENABLED = False in the test config, and checked the mail outbox, so the limit is proven to stop the fourth email and not just the fourth page.
Frequently asked questions
Does an unknown email count toward the limit?
Yes. Every POST with an address counts, registered or not, so the response never tells an attacker which emails exist. Someone can still send a victim up to 3 reset mails an hour.
Why is GET not limited?
The decorator passes methods=['POST'], so viewing the form never uses up an attempt. test_get_is_not_limited sends four POSTs and then expects the form to load with 200.