Skip to main content

Detection

Configure how AgentXP identifies AI agents from incoming requests.
AgentXP inspects each incoming request and determines whether it originates from an AI agent before deciding whether to serve markdown. You can configure which signals it uses and add your own bot patterns.

How detection works

AgentXP evaluates signals in priority order and stops at the first definitive match:
  1. accept-header — If the request includes Accept: text/markdown, AgentXP treats it as an agent with full confidence (1.0). This is a deliberate, unambiguous signal that the client expects markdown.
  2. user-agent — AgentXP matches the User-Agent string against a list of 20+ known bot patterns. A match yields confidence 0.9.
If no signal matches, the request is passed through unchanged to your Next.js application.

Configuration

middleware.ts

Options

signals

Type: ('accept-header' | 'user-agent' | 'http-signature')[] The detection methods AgentXP uses, evaluated in the order listed. Default: ['accept-header', 'user-agent'] To restrict detection to only one method, pass a single-element array:

customAgents

Type: { name: string; pattern: RegExp }[] Additional bot patterns to recognize beyond the built-in list. Each entry requires a human-readable name and a RegExp tested against the request’s User-Agent string. Default: []
Custom agents are checked after the built-in patterns. A match yields the same 0.9 confidence as other user-agent matches.

Built-in agent patterns

The following agents are recognized out of the box via the user-agent signal: For the full list with regex patterns, see Supported Agents.