Urgent.News

What's breaking now, across thousands of outlets.

AI

I built an agent that refuses to answer Next.js from stale docs

This is a submission for the Sanity Challenge, Path One: Ship an Agent That Queries Real Content What I Built Next.js changes fast and the old answer keeps ranking. fetch stopped caching by default, params became a Promise you await, next/font replaced @next/font , Turbopack became the default bundler. Ask a plain model "does the App Router cache fetch by default" and it will confidently say yes,…

This submission fulfills the Sanity Challenge, Path One, by creating an agent that queries real content. The agent built is named Still True. Next.js updates frequently, so the old answers become dated. The agent refuses to give stale or contradictory responses. It fetches answers from a Sanity Context Knowledge Base and highlights when sources disagree on a fact.

The agent surfaces which answer is current and shows the disagreement. For example, when asked if the App Router caches fetch by default, the agent confidently states no. It provides the awaiting code and notes that Next.js 14's synchronous method is now deprecated. The agent also checks which .env.local variables are available in the browser and flags any that aren't.

Every answer lists the Knowledge Base entries it sourced the answer from, so the user can verify the grounding. The agent uses a tool-use loop, handing retrieval to the model through three Sanity Context tools. It starts by listing the Knowledge Base, then reads the full entries the model picks, and finally lists any conflicts. The model reads the Knowledge Base outline first, picks matching entries, and only widens its search if evidence is thin.

The agent reports its toolTrace for every answer, showing which entries it consulted. If the Knowledge Base lacks relevant information, the agent declines to answer instead of making up information. The project is built on Sanity Context and a Knowledge Base containing both current and older Next.js guidance. The agent reads the full set of sources, not just a keyword search result, to provide accurate and up-to-date information.

The entire pipeline is headless, running from the CLI with the Sanity Context client, via the agent/ standalone CLI or the /api/ask server route. The agent talks to any OpenAI-compatible model through an environment variable. The public routes are rate limited and same-origin guarded due to cost considerations. The Knowledge Base consists of real Next.js source material, including pairs of conflicting guidance.

The Sanity Context distilled these sources into cited entries, handling both reconciliation (combining compatible entries) and conflict raising (highlighting incompatible ones). In the demo, the agent shows the fetch caching conflict between current Next.js guidance and older deprecated practices. The agent was generated and verified using Claude Code, ensuring the schema, Knowledge Base pipeline, and grounded agent are all correctly implemented.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

More from Thursday 24 September →