Skip to content
Ask

Cloudflare stack

Binding Product Role
AI Workers AI (+ AI Gateway) Embeddings and chat completion
VECTORIZE Vectorize Semantic search over doc chunks
DOCS KV Full page Markdown + nav JSON
SESSION KV Astro sessions + rate-limit counters
DocsAgent Durable Object Chat agent with SQLite history
ASSETS Static Assets Prerendered Starlight HTML/CSS/JS

DocsAgent extends AIChatAgent from @cloudflare/ai-chat. On each turn it:

  1. Persists messages in SQLite on the Durable Object
  2. Applies a per-session rate limit (via SESSION / DOCS KV)
  3. Retrieves relevant chunks (lexical over KV locally; Vectorize when available)
  4. Generates a grounded answer with Workers AI (generateText)
  5. Attaches citation metadata for the chat UI
  • POST /api/prompton/reindex requires x-prompton-reindex-secret (or Authorization: Bearer …) and is rate-limited per client IP
  • Optionally set Worker var PROMPTON_REINDEX_ALLOW_ACCESS=1 and protect /api/prompton/reindex with Cloudflare Access — Access-authenticated requests may reindex without the shared secret
  • /agents/* connection attempts are rate-limited per client IP
  • Chat turns are rate-limited per session Durable Object name

The custom Worker routes /agents/* to the Agents SDK first, then falls through to Astro:

import { handle } from "@astrojs/cloudflare/handler";
import { routeAgentRequest } from "agents";
import { DocsAgent } from "@prompton-dev/agent";
export { DocsAgent };
export default {
async fetch(request, env, ctx) {
const agentResponse = await routeAgentRequest(request, env);
if (agentResponse) return agentResponse;
return handle(request, env, ctx);
},
};

Chat with the docs

Loading chat…