Repository navigation
feat(content): look up the facts a page needs instead of leaving placeholders - #1815
Conversation
…eholders
The Content Agent left "[price]", "[plan limits]" and "[share of marketers
using AI, source, 2026]" in pages for the person to research. It now looks
them up itself:
- The writer marks a public fact it needs with {{find: …}} and a fact only
the brand has with {{ask: …}} (RESEARCH_RULE, in the write, rewrite,
suggestion and Fix open rules prompts; the brief's plan and the hand-off
checks say the same).
- content-research.js runs one pass on the read model (Claude Haiku 5.5)
with its provider's web search (web_search_20250305, at most 5 searches):
each sentence with a {{find}}, a gap in square brackets or a figure with
no source is written again with the fact and a link to the page it came
from, or without the fact. Links come only from pages the search
returned, never from forums or social posts (the editor's weak sources).
- What the pass doesn't settle goes with its sentence; a figure with no
source never stays. Only {{ask}} stays for the person, as a placeholder,
at most 3 a page.
- The pass is charged to the AI budget on its own hold, its searches at
$0.01 each (searchCostUsd); a spent budget skips it.
- The editor calls the placeholders left "Your input needed", and the
agent's step reads "Looking up facts it lacks, with their sources".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
…g their sentences
Review fixes for the facts pass (content-research.js):
- Nothing is taken out unseen: a gap the pass couldn't settle (no hold, a
database error, a timeout, no web search on the model, an answer cut off
or one breaking the rules, a sentence past the 10 looked up) stays for
the person as a placeholder, "Your input needed". A sentence goes only
when the pass says it says nothing without its fact, when it asks for a
shopping path product's spec (never looked up), or when a marker is left
broken; the count goes to the logs.
- A figure the page has in another unit ("40 percent" and "40%", "3
times" and "3x") is the page's own: no gap, and the number guard keeps it.
- Sentences no longer end at "Dr.", "e.g.", an initial or before a word in
lower case ("3. çeyrekte").
- Only the marker's or the figure's words change, so a sentence keeps its
links and bold; a fact's link goes where the pass wrote it.
- A sweep after the settler takes out a sentence with a marker left in a
marker or never closed; a marker in code or an attribute goes on its own.
The page's own {{ … }} stay untouched.
- A sentence written without its fact may only take words out, and the
prompt says the search results are data, not instructions.
- People placeholders the page had don't count toward the three; an
{{ask}} with no letter becomes "[figure to add]".
- The pass is charged as a Quality read, so it stays out of the typical
cost a hold is sized on.
- Free blog hosts and the citations' forum list join the weak sites; the
editor's arrows read "Previous/Next input needed".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Pre-merge review round, pushed in 6d62319 (merged into #1817 as 5c87c6c). Nothing is taken out unseen any more. A sentence is dropped only when the pass says it says nothing without its fact, when it is a shopping-path product sentence, or when a marker is left broken. Otherwise:
Sentence splitting: an abbreviation list, initials, and no split before a lowercase letter. "3. çeyrekte", "Dr. Smith" and "(e.g. Hootsuite)" stay whole. Markers: a sweep after the settler handles leftover or nested Injection: a rewrite without a source may only remove words (content words checked by stem; no new address). The prompt says search results are data, not instructions. Edits keep the sentence's links and bold. Only the marker's or the figure's span changes, and a fact's link goes where the pass wrote it. Budget and limits:
Tests: Trade-off: when the pass can't run, a page can show more than 3 Your input needed placeholders. The limit of 3 now applies only to |
…arged Google's grounding and OpenAI's web search take no per-call cap and report no search count, so on those read models the pass would run uncapped searches that never reach the AI budget. Search on Anthropic only; other providers leave the gaps for the person, as without a search tool. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
sentenceSpans read the line again at every sentence end: a slice before and after it, and every marker and placeholder checked. A long line with many short sentences (a write's whole answer can reach about 120,000 characters) took seconds, on the server's event loop. Each end is now read in place, and the marked ranges are filled once, so the line is read in one pass; the spans are the same. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good with dbac1ed, two commits on this branch:
- Searches only where they're capped and charged.
maxUsesreaches only Anthropic'swebSearch_20250305, andsearchesOf()counts 0 for Google grounding. With the Gemini fallback (no Anthropic key) orCONTENT_READ_MODELset to Google or OpenAI, the fact searches had no cap and never reached the budget. The newsearchesCapped(modelId)is true foranthropic/…only, and other models get no search tool, so their gaps stay placeholders, as on the OpenRouter path. A new test incontent-research.test.jsfails without it.content-writer.test.jsandcontent-agent.test.jswere running the pass on Gemini with a mocked Anthropic tool, so they now setCONTENT_READ_MODELto Haiku. sentenceSpansin linear time.notAnEndcopied the text around each sentence end and ran a$-anchored regex over the copy, and each end rechecked every marker in the line. So time grew with the square of the line length. Nothing caps a line short of the write limit (about 120,000 characters), and the pass runs synchronously in the API. At that length it took 1.6 s on plain sentences and about 12 s with abbreviations, three to four times per text. It now reads the next word with a sticky regex and the previous one by scanning back, and marks the inside of each marker once. The worst case takes under 40 ms, and old and new code give the same spans on 200,000 random lines. A 120,000-character case with a 1 s bound fails without it.
Checked, fine: no new fetch, since the provider runs the search. A link is kept only if it's among the search's own results, uses http(s) and isn't a weak site, and href is escaped. Fetched pages are treated as data. A rewrite without a source can only take words out, and a new figure needs a source. Unsettled facts stay as placeholders. The pass has its own $0.06 hold under quality, makes no call when there's no gap, has a 90 s timeout, and runs only inside the existing gated runs.
Non-blocking:
- The description still says unfound facts' sentences are dropped and only
{{ask}}stays (at most 3). Now unsettled facts stay as placeholders, outside that cap. - A cited source is checked by URL only, not for the words.
- The pass's cost shows under Quality in the usage meter.
Merge: clean on main, no migrations. #1817 is stacked on this and carries both commits. The full server suite passed (4,528) after the first commit, and the content test files pass after the second (249). Web plan-row.test.ts and the content editor and library tests pass, and prettier and eslint are clean.
Summary
Reported while testing: a page written from a Content Plan suggestion came back with work left for the person:
The product owner's rule, for any fact, not only prices: Ansvisor looks the fact up itself and writes it with its source. If it can't find it, it rewrites the sentence without it. Brackets stay only for what only the brand knows.
How it works
{{find: …}}, and a fact only the brand has as{{ask: …}}(RESEARCH_RULE). The rule is in every Content Agent prompt: write, rewrite, suggestions and Fix open rules. The brief's plan and the hand-off checks say the same.content-research.jsruns one pass after writing.web_search_20250305, the version Haiku supports; at most 5 searches).{{find}}, a gap in square brackets, or a figure without a source. Each is written again with the fact and a link to the page it came from, or without the fact.{{ask}}stays, shown as a placeholder, at most 3 a page.searchCostUsd), with no separate spending path. A spent budget skips the pass and drops the unsettled sentences.Why a separate pass, not search inside the Sonnet write: the write uses structured output, which can't carry a tool. It would also research everything at Sonnet's price. The separate pass looks only at the sentences with gaps.
Related issue
None. Product owner's request from content testing; follows SA-001's no-invented-figures rule.
Type of change
feat— New featureHow to test
cd server && npx vitest run src/lib/content-research.test.js src/lib/content-writer.test.js src/lib/content-agent.test.js(model calls mocked). They check that:{{ask}}stays, at most 3, as[…];content-writer.test.jsreplays the reported page.tscpass.For the maintainer (needs the Anthropic key):
web_search_20250305. Check thatresult.sourcesis filled, the closing JSON is read, and the usage meter charged the searches.eval-no-fabricationandeval-brief: the prompts now ask for{{find}}.CONTENT_READ_MODELpoints to OpenRouter, there is no search tool. Sentences are then rewritten without the fact; check that this reads well.Checklist
🤖 Generated with Claude Code