Skip to content

feat(content): keep figure placeholders out of briefs - #1817

Merged
gkhngyk merged 9 commits into
ansvisor:mainfrom
cihan-gyk:feature/brief-no-figure-placeholders
Oct 30, 2026
Merged

gkhngyk merged 9 commits into
ansvisor:mainfrom
cihan-gyk:feature/brief-no-figure-placeholders

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #1815. Brief generation (Rebuild outline) no longer writes [figure, source] placeholders.

Related issue

Follows #1815 (same rule for briefs).

Type of change

  • feat — New feature

How to test

cd server && npx vitest run src/lib/content-brief*.test.js. A brief built from data without a source for a figure has no [figure, source].

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • Server: format, lint and the related tests pass
  • Tests updated

🤖 Generated with Claude Code

cihan-gyk and others added 4 commits October 30, 2026 01:30
…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]>
…placeholder

Rebuild outline turned a figure its sources didn't have into
"[figure, source]" in the brief, a gap the person was left to research.
The writer now looks a fact up itself (content-research.js), so the
brief names it in words:

- briefGuard takes a figure it adds out with its sentence (a heading loses
  the figure alone: withoutFigures); a key point, an answer, a claim or a
  TL;DR left with nothing goes. A person or a quote it wasn't given stays
  a placeholder, the brand's to name.
- The brief eval's judge reads a fact named without its figure as one the
  writer looks up; its samples name the fact in words.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…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]>
…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
gkhngyk previously approved these changes Oct 30, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with 9ca9131. This PR's own change needs nothing, so the commit only merges in #1815's two fixes (searches only on capped and charged models, and sentenceSpans in linear time). The merge is clean because they touch content-research.js, its test and two test setups, which this PR doesn't change. On this head the content research, writer, agent, brief and brief-eval tests pass.

What changes here. briefGuard().text passes its result through withoutFigures. In body text, a sentence holding [figure, source] is dropped. In a heading only the placeholder is removed. People and quote placeholders are untouched. Every field it reaches already handles an empty result. It runs only on the model's answer in rebuildDraftBrief and the brief eval, so briefs someone edited and stored briefs are never rewritten. Older briefs with [figure, source] render as before. The brief prompt, briefForWriter ({{find: …}}) and the judge prompt agree. The new heading regexes are linear.

Notes (not blocking)

  1. Headings can come out broken: "Why 73% of CFOs distrust forecasts" → "Why of CFOs distrust forecasts", "Under $900" → "Under". The new test also locks in "Prices in, plan by plan". When the guard changes a heading of a section that answers a fan-out, the fan-out's words could be used instead.
  2. sentenceSpans doesn't split on line breaks, so "First line\nSecond line with 40%" loses both lines. Splitting on \n too would make it safe.

Merge: order #1815, then this PR. #1816 can go in at any point; the two share only web/messages/en.json, with different keys. Clean on main, no migrations. Before the merge commit, the full server suite passed (331 files; the timing tests pass alone), along with 44 web test files including plan-row.test.ts.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging in order with the other approved PRs. This head merges current main; its tree is what main will be after this squash, checked with the full server and web suites, tsc, lint, format and next build.

@gkhngyk
gkhngyk merged commit d192ebd into ansvisor:main Oct 30, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants