Inspiration
AI agents are no longer just bots scraping content — they're autonomous systems that drive real browsers, click buttons, fill forms, and navigate sites exactly like a human would. As someone with a DevOps background, I kept thinking about the same scenario: a solo developer or small startup deploys a Next.js app on Vercel, and a rogue AI agent loop quietly racks up thousands of serverless invocations overnight. Standard firewalls can't catch this — the agent uses valid JavaScript, real browser fingerprints, and looks indistinguishable from a person. I wanted to build something that catches the behavior, not the headers.
What it does
AgentShield is an edge-layer firewall that scores every visitor using three independent behavioral signals:
- Honeypot trap — an invisible form field only a script would interact with
- Keystroke uniformity — measuring variance in typing rhythm
- Mouse path linearity — comparing straight-line distance vs. actual path traveled
Each session gets a composite score from 0–1, stored in real time in Amazon DynamoDB. When a score crosses the threshold, the IP is automatically written to a blocklist, and Vercel Edge Middleware enforces a 403 globally on the very next request — before it ever reaches a serverless function. A live dashboard lets you see every session's score and manually block or unblock any IP with one click.
How I built it
The stack is Next.js, deployed on Vercel, using Edge Middleware (proxy.ts) for enforcement and Amazon DynamoDB as a single-table store for both session telemetry and the blocklist. The detection logic itself is intentionally heuristic rather than ML-based — standard deviation of keystroke intervals, and a ratio between straight-line distance and total path length for mouse movement — so it's fast, explainable, and runs entirely within DynamoDB's free tier (provisioned at 20 WCU/20 RCU). I built and tested everything locally first using WSL2 and a Playwright bot script that simulates an AI agent — perfectly straight mouse movement, zero-variance keystrokes — before deploying it live and re-running that same bot against the production URL to confirm the detection held up in the real environment.
Challenges I faced
A few real ones, in order:
- IPv6 localhost. Local testing initially failed because
::1(IPv6 localhost) didn't match the127.0.0.1blocklist entry I'd created manually — a good reminder that real-world IP handling needs to account for both formats. - A genuinely strange Vercel deployment bug. My first production deployment built successfully and listed every route correctly in the build logs, yet every single page returned a 404 with zero runtime logs generated. After ruling out Deployment Protection, environment variables, and middleware, the actual cause was the project's Framework Preset being set to "Other" instead of "Next.js" — once corrected, everything worked immediately.
Accomplishments that we're proud of
Getting the full detection-to-block loop working end-to-end, automatically, with zero manual intervention. A real Playwright bot — simulating straight-line mouse movement and zero-variance keystrokes — gets caught, scored, and blocked at the edge without anyone touching DynamoDB by hand. Proving this worked not just on localhost but against the actual live Vercel deployment, with the bot script re-run successfully in production.
What we learned
How quickly assumptions break in production versus local development — middleware silently failing due to a framework rename, IPv6 vs IPv4 localhost mismatches, and a deployment that built cleanly yet served nothing until a single misconfigured Framework Preset setting was found.
What's next for AgentShield
The current version is intentionally a focused MVP — single-site, no authentication, binary block/allow. The next phase moves toward a genuinely multi-tenant product: user accounts so any team can register and protect their own site, a settings page with tiered pricing (Free / Starter / Team), and a response system — monitor, throttle, then block.
Built With
- amazon-dynamodb
- amazon-web-services
- nextjs
- node.js
- playwright
- react
- typescript
- vercel
- vercel-edge-middleware
Log in or sign up for Devpost to join the conversation.