Skip to content

Add AI agent detection via @vercel/agent-readability#324

Open
molebox wants to merge 2 commits intomainfrom
add-agent-readability
Open

Add AI agent detection via @vercel/agent-readability#324
molebox wants to merge 2 commits intomainfrom
add-agent-readability

Conversation

@molebox
Copy link
Copy Markdown
Contributor

@molebox molebox commented Apr 2, 2026

Summary

  • Adds @vercel/agent-readability package for AI agent detection in middleware
  • Detected agents get markdown responses instead of HTML for better AI consumption
  • Non-existent docs URLs return helpful not-found markdown with discovery links
  • Accept header content negotiation continues to work as before

Matches the geistdocs template (vercel/geistdocs#58). Uses the same shared package as vercel/front#65649.

Test plan

  • AI agent hitting a valid docs URL gets markdown rewrite
  • AI agent hitting a non-existent docs URL gets not-found markdown
  • Normal browser requests unaffected
  • Build passes

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 2, 2026

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

Project Deployment Actions Updated (UTC)
chat Error Error Apr 2, 2026 11:07am
chat-sdk-nextjs-chat Error Error Apr 2, 2026 11:07am

@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​vercel/​agent-readability@​0.2.17810010095100

View full report

trackMdRequest({
path: pathname,
userAgent: request.headers.get("user-agent"),
referer: request.headers.get("referer"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeScript compilation error: trackMdRequest is called with requestType: "agent-rewrite" and detectionMethod which are not defined in the TrackMdRequestParams interface.

Fix on Vercel

);
return NextResponse.rewrite(new URL(result, request.nextUrl));
}
// Agent requested a non-existent docs URL
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not-found response for AI agents returns HTTP 200 instead of HTTP 404, making it indistinguishable from a successful response.

Fix on Vercel

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