This article details the architectural choices and components used to build Cloudflare Radar Researcher, an AI tool that allows users to explore internet traffic data using natural language. It highlights the use of Cloudflare Workers, Durable Objects, Workers AI, and AI Gateway, demonstrating how these services integrate to create a stateful, scalable, and intelligent data querying system.
Read original on Cloudflare BlogCloudflare Radar Researcher is an AI agent built entirely on Cloudflare's developer platform, showcasing a practical application of serverless functions, stateful objects, and AI inference. The system is designed to democratize access to Cloudflare's vast internet data by allowing users to ask questions in plain language and receive interactive visualizations and explanations.
Resilience in AI Systems
The use of an ordered fallback chain for AI models in Workers AI is a critical design decision for resilience. By having multiple model families, the system can transparently cascade requests to the next available model if one is at capacity or experiences an incident, significantly improving system reliability and uptime.
When a user asks a question, the Cloudflare Worker receives it and passes it to the Workers AI for interpretation. The AI, equipped with tools for searching and executing against the Radar API's OpenAPI spec, formulates a query. This query is executed via the MCP server, fetching live data. The model then generates a response, including lightweight chart specifications. The frontend Worker then uses these specifications to render interactive charts and presents the complete answer to the user. Contextual information like current date, time, and user's IP location are also passed to the AI to tailor answers.
{
"user_query": "Internet quality in Portugal?",
"worker_action": "parse_query_and_context",
"ai_gateway_route": "workers_ai/kimi_k2.7_fallback",
"ai_tool_call": {
"tool": "execute",
"args": {
"api_endpoint": "/internet_quality",
"parameters": {"country": "Portugal"}
}
},
"api_response": {"data": "..."},
"model_output": {
"text": "... explanation ...",
"chart_spec": {"dataFrom": "/internet_quality", "type": "time_series"}
},
"frontend_render": "interactive_chart_and_text"
}The entire system leverages Cloudflare's ecosystem, from compute (Workers) to inference (Workers AI) to storage (R2 for conversation history) and data access, demonstrating a vertically integrated architecture for building intelligent applications.