What the agent does
The agent reads the service before it writes a line of YAML. In a service shaped like aws-node-express-api in serverless/examples, serverless.yml names the service aws-node-express-api, pins frameworkVersion: "4", runs on nodejs24.x with architecture: arm64, and declares one function, api, with handler: handler.handler and a single httpApi: "*" event. handler.js builds an Express 5 app with GET / and GET /hello routes and a 404 handler, and exports it through serverless-http 4. package.json lists only express and serverless-http, there are no tests, and the README notes that the deployed API is public and anyone can call it.
That shape decides the approach. An httpApi event is an API Gateway HTTP API, where throttling is a property of the stage and its routes, not of a usage plan: usage plans, API keys and per-client quotas exist only on REST APIs, which the framework exposes through http events and provider.apiGateway.usagePlan, the way aws-node-dynamic-image-resizer in the same repository sets a monthly quota and a burst limit. The framework has no throttle key under provider.httpApi, so the agent uses resources.extensions to extend the stage the framework generates, whose logical id is HttpApiStage, with DefaultRouteSettings carrying ThrottlingRateLimit and ThrottlingBurstLimit taken from the issue. Because the service routes everything through httpApi: "*", there is one $default route and no per-route settings to add; the agent says so in the pull request rather than inventing routes.
Then it proves the change without deploying. Framework v4 asks for a Serverless access key before it will package, so the agent reads SERVERLESS_ACCESS_KEY from the Project's secrets when one is there, runs npm install and serverless package, and reads .serverless/cloudformation-template-update-stack.json to find the AWS::ApiGatewayV2::Stage resource with the two throttling values on DefaultRouteSettings. It adds a node --test test under test/ that packages the service and asserts on those two numbers in the generated template, and a test script in package.json to run it, so the check lives on in the repository. When the issue also asks for a per-client limit, the agent explains in the pull request that an in-memory counter in handler.js would reset on every Lambda cold start and differ between concurrent containers, and offers either a REST API with a usage plan or a DynamoDB-backed counter as a follow-up instead of shipping a limit that does not hold.
The pull request description quotes the issue, states the rate and burst it set, explains that API Gateway answers a throttled request with 429 Too Many Requests and no Retry-After header, and notes that the stage default applies per account per region across the stage, not per caller. The run leaves handler.js untouched unless the issue asked for a change in behaviour.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "A Linear issue labelled agent says: \"Rate limit the public HTTP API: steady 50 requests per second with a burst of 100, so a misbehaving client cannot run up the Lambda bill. Keep the routes as they are.\" Do the work in this Serverless Framework service. Read serverless.yml, handler.js, package.json and README.md first, and look at how other services in the repository set throttling if any do. The event is httpApi, so do not add a REST API usage plan or API keys; extend the generated HttpApiStage resource through resources.extensions with DefaultRouteSettings carrying ThrottlingRateLimit and ThrottlingBurstLimit from the issue. Run npm install and serverless package using SERVERLESS_ACCESS_KEY from the environment, read the generated CloudFormation template under .serverless and confirm the AWS::ApiGatewayV2::Stage resource carries both values, and add a node --test test that packages and asserts on them, with a test script in package.json. Do not deploy. Open a pull request that quotes the issue, says what a throttled client receives, and explains why no per-client limit is included.",
"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
What comes back is a pull request on its own branch that changes serverless.yml to add a resources.extensions.HttpApiStage block with DefaultRouteSettings, adds test/throttling.test.js and a test script to package.json, and leaves handler.js as it was. The description quotes the Linear issue, shows the AWS::ApiGatewayV2::Stage fragment from the packaged template with the rate and burst values, and links back to the issue.
The checks on the pull request are npm test, which runs serverless package and the assertion, and whatever workflow the repository already runs. The run's record keeps the serverless package output and the template lines the agent read, so a reviewer sees the resource that serverless deploy would create before anything reaches AWS. No deploy is claimed.
Before merging, a reviewer checks that the numbers match the issue, that the account-level API Gateway limits in the target region are above the burst, that the service really has one $default route so a stage default is enough, and that the client teams know a 429 can now arrive. Then they deploy to a dev stage and watch the 4XXError metric for the stage while a load tool exceeds the burst.
Run it on every Linear issue labelled agent
Sign in to Linear once with POST /me/connections {"type": "app", "name": "linear"} and finish the authorize URL in the console. Then add an automation to the Project with this prompt and a linear trigger on linear.issue.labeled, naming the label in its labels setting. The trigger adds the issue after the prompt and fills in no placeholder, so the agent reads the rate, the burst and the scope from the issue, and the pull request links back to it. The automation's max_runs_per_hour, between 1 and 30, caps how many labelled issues it takes on in an hour, each in its own sandbox with its own pull request.
A Project secret named SERVERLESS_ACCESS_KEY reaches every session in that Project without being named, so the automation's runs can package the service. Without an automation, a handler on your server that receives Linear's webhook sends this request with the issue text in input and the issue URL in resources beside the repository, with a request_id that is a UUID v5 of the issue id so a redelivered webhook returns the run already started.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
The hard part of throttling an HTTP API is not the two numbers but knowing where they go: httpApi and http events are different API Gateway products with different knobs, and the framework's own schema will not tell you that throttle belongs to one and not the other. On Rush the agent reads the event type, picks the stage extension, and proves it by packaging in its own sandbox with the access key from a Project secret, so the pull request shows the generated CloudFormation rather than a guess about it.
Every command and the template lines it read stay in the run's record, the test it added keeps checking the stage settings on every future change, and nothing is deployed until a person merges. Several labelled issues on several services start several sandboxes at once, each with its own branch and pull request.
Frequently asked questions
Why not a usage plan with API keys?
Usage plans, API keys and per-client quotas belong to REST APIs, which the framework exposes through http events. This service uses httpApi, an HTTP API, where throttling is set on the stage and its routes. Switching the event type would change the URL shape, the payload format serverless-http receives and the cost, so the agent stays on the HTTP API unless the issue asks for keys.
Is the limit per client?
No. Stage and route throttling on an HTTP API applies to the whole stage, so one noisy client can still consume the shared budget. A per-client limit needs a REST API usage plan keyed by API key, or a store such as DynamoDB that every Lambda container reads, and the pull request names both as follow-ups rather than shipping an in-memory counter that resets on each cold start.
What does a throttled caller see?
API Gateway answers 429 Too Many Requests before the request reaches Lambda, so the function is not invoked and not billed for it. There is no Retry-After header on that response; clients should back off with jitter, and the pull request description says so for the teams that call the API.
Does it need my AWS credentials?
No. serverless package resolves variables and writes the CloudFormation template locally without touching AWS. It does need a Serverless access key under framework v4, which the agent reads from a Project secret named SERVERLESS_ACCESS_KEY; without one, the agent still edits serverless.yml and says in the pull request that packaging was skipped.
More Serverless Framework jobs
The same job on other stacks
- Add Rate Limiting to a Slim 4 App (Slim)
- Add Rate Limiting to a Socket.IO Chat Server (Socket.IO)
- Add Rate Limiting to a Symfony App (Symfony)