Skip to content
All writing
5 min read Updated November 19, 2026

An AI agent that discovers the news and drafts it

Fibre2Fashion's news desk spent every morning searching dozens of sources by hand, judging what mattered, confirming it, then writing it up. A two-phase agent now does the finding and the drafting, with an editor choosing what gets pursued: the morning scan is one click and a de-duplicated shortlist of 20 to 30 stories.

AI AgentsPythonFastAPILLMs
On this page

Every morning, a news desk does the same thing: open Google, visit a few dozen competitor and source sites across 17 countries, decide what's actually relevant, confirm each story against a primary source, and rewrite it in house style. It's hours of repetitive triage, and because it's manual there's no memory across days and no consistent ranking of what mattered.

I built an agent that reproduces that routine for a textile and apparel newsroom (the case study). It now does the finding and the first draft, and the editor's job shifts from doing the triage to deciding on it: the manual morning scan is one click and a de-duplicated shortlist of 20 to 30 stories ready to draft.

That is why the rest of this post is about cost and trust rather than prompting. The hard part wasn't calling an LLM. It was making the thing cheap, trustworthy and controllable enough that an editor would actually hand it the morning.

Why two phases

The naive version is one big pipeline: search everything, fetch every page, summarise, rank, draft. That's expensive and slow, because you pay full-text fetch and LLM cost on stories nobody wanted.

So I split it in two, with a human in the middle:

  1. Discovery (cheap). The beat and about 40 textile, trade and economic topics become date-aware search queries. The agent reads around 65 primary and 75 secondary sources across 17 countries, using each site's RSS feed where it has one and Google News for sites that block bots or publish no feed. A small model then scores, de-duplicates and ranks what it found.
  2. Pursuit (expensive, opt-in). The editor ticks the stories worth chasing. Only those get the full-text fetch, clustering into distinct candidates, primary-source confirmation and one-click drafting.

That single boundary, letting a human pick before anything expensive runs, is what keeps the economics sane. The model triages, the editor decides, and the expensive work runs on a shortlist.

Getting the inputs without getting blocked

Discovery is only as good as what it can read. The harvest is RSS-first: if a source publishes a feed, configured or auto-discovered, the agent prefers it over scraping. When a page is bot-walled, it falls back to a search snippet, so a blocked URL never silently drops a story.

For the pages that do need fetching, the extractor is layered: trafilatura, then JSON-LD, then the article container, then a paragraph sweep. A bot-wall detector re-fetches through Playwright when the cheap path returns junk, so messy or hostile pages still yield clean copy more often than not.

Ranking and de-duplication

An LLM judges relevance as direct or indirect to the beat, collapses the same story told by five different outlets into one item, and ranks what's left by newsworthiness, source authority and recency. De-duplication across scans (URL, content hash and headline overlap) means a story that appeared yesterday doesn't resurface today. Picking the right passages of a document, rather than ranking whole stories, is a related but different problem; I wrote about it in why my RAG kept returning the wrong chunks.

Confirming a story without paying for it

A draft is only safe if the story is real. I confirm each one against a primary source, but without an LLM call: a targeted search, a preference for higher-authority sources, and a title-overlap check (Jaccard similarity) that rejects loose matches. Cheap, deterministic, and good enough to catch the obvious fabrications and rumour-mill reposts.

When the primary source is a page you still have to open and read, Tabbit's walkthrough of following a claim back to the original passage covers how a browser agent can click through the citation, check the final URL, and capture the named section before the story is drafted.

Provider-agnostic by design

The LLM layer works with OpenAI, Gemini or Claude, all in JSON mode with backoff retries and per-job token accounting. That matters for cost: high-volume discovery runs on a small, fast model, while drafting, where quality shows, can use a stronger one. Swapping providers is a config change, not a rewrite.

Production hardening is the actual work

Getting it to run was the short part. This is what made it safe to leave running, covered by 375 tests across 43 files:

  • SSRF-guarded fetching. It follows URLs the internet hands it, so the fetcher refuses private and loopback addresses.
  • robots.txt and rate limits on every outbound request.
  • Per-job token and URL budgets, so one runaway job can't burn the month's spend.
  • Retries with backoff, structured JSON logs and Prometheus metrics.
  • A watchdog that restarts a stuck worker, and recovery for jobs interrupted by a restart, so no scan is silently lost.

Streaming the work, not just the result

Every step, each query, each source, each judgement, streams to the editor live over Server-Sent Events. That turned out to be more than polish: a visible activity log is what makes an agent trustworthy. When you can watch it reason and reject, you stop second-guessing it. One config-driven client serves two hosts, a FastAPI app and the company's .NET admin portal, so a fix ships once.

What I'd tell my past self

  • Put the human at the most expensive boundary. Don't ask for approval on trivia; ask right before the costly work.
  • Be deterministic where you can afford it. Confirmation didn't need an LLM, and not using one made it cheaper and easier to reason about.
  • Observability is a feature. The live log is the difference between a demo and a tool people rely on.

The result is a morning that starts from a ranked shortlist instead of a blank browser.

Next, the editors' picks are a labelled dataset nobody uses yet: every morning they choose some stories and skip the rest. I want to store each shortlist with what the editor kept and feed it back into the ranking, holding some exploration back so it doesn't only learn its own taste.

Frequently asked questions

What is a two-phase AI agent?
It splits the work into a cheap discovery phase, where an LLM scores and ranks candidates, and an expensive pursuit phase that only runs on the items a human picks. You never pay full-text fetch and generation cost on stories nobody wanted.
How do you keep an LLM agent's costs down?
Put the human at the most expensive boundary, run high-volume triage on a small fast model and reserve a stronger model for drafting, cap per-job token and URL budgets, and use deterministic checks instead of LLM calls wherever they're good enough.
Why stream agent steps over Server-Sent Events?
A live activity log is what makes an agentic system trustable — when an editor can watch it search, judge, and reject in real time, they stop second-guessing it. SSE is a simple one-way stream that fits this perfectly.
How do you stop an AI agent from drafting fake news?
Each story is confirmed against a primary source before drafting — a targeted search with source-authority preference and a title-overlap guard — which catches obvious fabrications and rumor reposts without spending an extra LLM call.
// The project behind this essay
News Desk — Human-in-the-Loop Story-Discovery Agent — case study by Manuj Rai

News Desk

Human-in-the-Loop Story-Discovery Agent

An automated newsroom agent that reproduces an editorial team's morning routine — harvests ~65 primary and ~75 secondary curated source pages across 17 countries for textile/apparel news, scores and de-dupes the best stories with an LLM, confirms each against its primary source, then drafts publish-ready articles. Two-phase with a human in the loop, streamed live over SSE.

Python 3.11 · FastAPI · OpenAI · Gemini · Claude

// Continue reading