Skip to content

feat(content): have the Content Agent read a version 2 brief's plan, keep headings short and write without keyword stuffing, behind CONTENT_BRIEF_RULES (brief rules PR 8) - #1547

Merged
gkhngyk merged 17 commits into
ansvisor:mainfrom
cihan-gyk:feature/brief-writer-v2
Oct 26, 2026

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Brief rules 2026, PR 8 of 10: the Content Agent reads a version 2 brief's plan.

What the agent is told, with the flag on

The plan (briefForWriter, in content-brief.js). After the brief's goal, outline and keywords, a version 2 brief adds:

  • the TL;DR the page's top must say, and the angle only this page can show;
  • each section's plan: its answer first, how to show it, and the facts to give.
    • A table is asked for as a comparison set out point by point, since no page the agent writes has a table yet.
    • A fact from Your input is named by its label.
    • A fact to check against a cited page is a placeholder: the agent never sees that page's words.
    • A fact with no source is a placeholder until one is found.
  • the proof to gather, written only from Your input, else a placeholder;
  • the searches left to another page ("keep to one topic");
  • freshness: the dated point, an "Updated" line, and the year in the title when it writes the title;
  • the names, written exactly so;
  • the links planned. They're never an allow list: the links rule and linkAllowList still decide every link.
    • A new page's writer has no links rule, so it isn't told of them.
    • Suggestions and a rewrite are told of them.

The prompts.

  • Write, suggest and rewrite each get the guardrail (Bing's February 2026 guidelines): "No keyword stuffing, and no wording made to trigger a citation: write for the reader."
  • Write also gets two lines:
    • follow the brief's section plans;
    • headings are one short line: the title up to 70 characters, each section heading about 8 to 15 words (a fan-out's own words when shorter) and under 90 characters. These are the editor's limits (HEADING_LIMITS).
  • writeSystemPrompt(), suggestSystemPrompt() and rewriteSystemPrompt() return the old constants with the flag off. All four calls use them (write, suggest, rewrite, and the rewrite's cut to length).

The guards

The numbers and names a run may write unmarked come partly from the brief. Their source is now the brief text without its web addresses:

  • a planned link's https://acme.example/top-37-tools would have let "37" through, and …/interview-with-john-smith would have let "John Smith" through;
  • this matches sourceWords, which already keeps a cited page's address out.

This also applies with the flag off: a brief someone typed an address into no longer vouches for that address's numbers and names. A version 1 brief rarely has one.

The no-fabrication eval

  • eval-no-fabrication.js asks with writeSystemPrompt(), so a run with the flag on checks the new write prompt.
  • recorded.json now notes briefRules: true|false, so a recording says which prompt it checked.
  • The pinned recording isn't changed here: PR 10 (gkhngyk) records again with the flag on.

Cost with the flag on

  • A full version 2 brief adds about 350 input tokens to each run (the sample brief's plan is about 1,400 characters). The write prompt adds about 100 more.
  • Output doesn't change.

Related issue

Roadmap CE-EVAL-001 / brief rules 2026 (no GitHub issue).

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Run the tests:
    cd server && npx vitest run src/lib/content-writer.test.js src/lib/content-brief.test.js
  2. With an AI key and CONTENT_BRIEF_RULES=true:
    • click Rebuild outline on a new-page draft, then Start: the page's sections should follow each section's answer, format and facts, with short headings;
    • on an existing page, start the Agent: its suggestions should follow the plan, and its links still go only to the pages the links rule offers.
  3. With the flag off, the same runs ask exactly as before.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/): no web changes
  • yarn typecheck passes (run from web/): no web changes
  • yarn format:check passes (run from web/): no web changes
  • Changes are focused — one concern per PR

Server checks, run locally after the review fixes: format and lint clean; 225 test files, 2,888 passed, 3 skipped (the eval's recorded-baseline tests). Root npm run version:check fails as it does on main (compose images 0.2.0); not changed here.

Tests:

  • Flag off: the three prompts equal the old constants; the brief reads as version 1 word for word.
  • Flag on:
    • each prompt has the guardrail, and the write prompt the plan and heading lines;
    • the plan's lines: TL;DR, angle, sections, proof, scope, freshness, names, links;
    • a fact's source by kind: Your input by its label, a cited page as "check it against", none as a placeholder;
    • no links line for a new page's writer, in briefForWriter, briefText and a real create run;
    • an existing page's suggestion run gets the guardrail and the links planned;
    • a rewrite run is told of the links, but "37" from /top-37-tools and "John Smith" from /interview-with-john-smith still become placeholders. This test fails without the fix.

Pre-push review

A review agent read the change before the push. Fixed from it:

  • the planned links' addresses vouched for numbers and names (high);
  • a fact's source was named as if the agent could read it (a cited page) or as a plain label (Your input);
  • a new page's writer was told of links it has no rule for;
  • wording: "about 8 to 15 words" now allows a fan-out's shorter words, and the year goes in the title only when the agent writes the title;
  • the guardrail's comment now says which prompts carry it (the Fix agent's don't);
  • test gaps: exact flag-off brief, the suggest and rewrite calls end to end;
  • the no-fabrication recording now notes the flag.

🤖 Generated with Claude Code

cihan-gyk and others added 17 commits October 26, 2026 04:31
…ave as a placeholder, so the writer can't take it as given

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aceholder in half, and test the audience, names in headings and Turkish percentages (pre-push review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s as a rubric, checks anyone can repeat with a gate on anything the brief wasn't given, a judge model's quoted scores, and a script that records them (CE-EVAL-001, brief rules PR 2)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e by line; record the model's own answers and check them again in the test; read quotes in any marks, shortened, three words at least, in one line the judge saw; version the prompt under Quality's phase and the schema; keep a partial run apart; compare addresses by host and path (pre-push review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ief behind CONTENT_BRIEF_RULES, with the data numbered, the page type's formats and the rules in effect; keep the facts' sources by kind and ref, cut to the web's version 2 limits and fit under 64 KB (brief rules PR 4)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…umber only the cited pages as sources, take the rules beside the sources, and read version 2's answers and facts in the brief eval (pre-push review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…N schema only, so an off-list value never fails a charged call; take out only the page numbers given; match a fan-out as listed before its unquoted form; ask the judge for H2 lengths only (pre-push review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… its essentials, angle, the brand's own proof to gather, the fan-outs left for another page and freshness by page type, with Brief › Your input numbered as sources (brief rules PR 5)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nt the eval's fan-out coverage over the fan-outs the brief keeps, and compare the input kind with the web's (pre-push review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…on-plan

# Conflicts:
#	server/.env.example
#	server/src/lib/content-brief-eval.js
#	server/src/lib/content-brief-eval.test.js
#	server/src/lib/content-brief.js
#	server/src/lib/content-brief.test.js
#	server/src/scripts/eval-brief.js
…n, and plan links to the brand's pages and the sources listed only, in the brief behind CONTENT_BRIEF_RULES (brief rules PR 6)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… past a failed competitors read, cap the pages' titles and skip addresses the web can't keep, drop a link whose words got a placeholder, and give the eval cases competitors and pages to link to (pre-push review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r-v2

# Conflicts:
#	server/src/lib/content-brief-eval.js
#	server/src/lib/content-brief-eval.test.js
#	server/src/lib/content-brief.js
#	server/src/lib/content-brief.test.js
…keep headings short and write without keyword stuffing or engineered wording, behind CONTENT_BRIEF_RULES (brief rules PR 8)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and name a fact's source by kind

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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 follow-ups.

What I checked:

  • With CONTENT_BRIEF_RULES off.
    • writeSystemPrompt(), suggestSystemPrompt() and rewriteSystemPrompt() return the constants as they were, and all four calls use them (write, suggest, rewrite, and the cut pass). The write and rewrite prompts equal main's, and the suggest prompt's text isn't touched.
    • briefForWriter returns '', so briefText gives main's text byte for byte. I compared main's output with this head's for four briefs, with links on and off. All were equal. The four:
      • a version 1 brief;
      • the web's version 2 sample;
      • an opportunity's brief;
      • no brief.
    • The eval's recording gains briefRules. no-fabrication.test.js reads cases by id, so the new key changes nothing.
  • The guards (these apply with the flag off too).
    • The numbers and names a Start may write unmarked now come from the brief without its http(s):// addresses. Fix, Quality's hand-off and the brief's own build don't read this.
    • The change only takes words out of what vouches, so nothing gets through that main stopped. No loophole.
    • Once the API is deployed, what changes is a number or a person's name that a brief holds only inside an address. Some examples:
    • What the agent does with such a number or name:
      • A new page or a rewrite writes "top [figure, source] grinders" or "[name of a real person] said", where main kept "10" and "Jane Doe".
      • On a live page, a suggestion that adds "10" is dropped unless one of its sources has it, and the name becomes a placeholder.
    • That's right: a slug isn't a source, and a page's own links never vouched either.
      • The same number written in the words still passes: "our top 10 grinders guide (https://…)".
      • A brief the model built rarely keeps such a number. The brief's own guard already writes "best-[figure, source]-espresso" in an address.
    • The one false refusal is in text without spaces. See item 2.
  • What the agent is told, with the flag on. I printed it for the web's sample: 1,437 characters, about 350 tokens.
    • Bounded. content_drafts.brief is at most 64 KB (00212). Each field is cut to the web's limits when the brief is built or edited.

    • Fenced.

      • Your input's labels, the link words and their H2s are in quotes. The other fields follow a label, as version 1's goal and key points do.
      • Only a source's title can bring outside words in, through a link's words. Those words are guarded, at most 120 characters and in quotes.
    • Facts. Each one is told by its source:

      • a fact from Your input names the item's label;
      • one with a cited page says "a placeholder: check it against , whose words you don't see";
      • one with no source says "a placeholder until a source is found".

      Whatever the model writes, a figure that nothing it was given has becomes a placeholder.

    • Links. Only pages listed are kept, as #1545 promised.

      • A new page's writer isn't told of them, and it can't write a link: renderPage escapes every text.
      • Suggestions keep a link only when it's on linkAllowList(targets). A rewrite keeps it there or on a link the page already has. Anything else is unwrapped to its words.
      • Their addresses never vouch (see above). The test with "/top-37-tools" and "/interview-with-john-smith" fails without briefGiven.
  • Short headings and no keyword stuffing. Both are prompt only.
    • The heading line is in the new page's prompt only. Suggestions and rewrites keep their own heading rules and checks, unchanged.
    • The guardrail goes into the write, suggest, rewrite and cut prompts.
    • There's no new check, so nothing new can refuse a good page or rewrite.
  • The work.
    • One new regex, /https?:\/\/\S+/g. It runs once per Start on the brief's text (from a brief of at most 64 KB), never on the page.
    • It has no alternation, no nested quantifier and no lookbehind. A try fails within 8 characters, and a match ends at the first space, so it's linear.
    • On 100 KB inputs it took under 0.2 ms. The inputs: spaces, capitals, initials, punctuation, digits, a keyword repeated, "http://" with no spaces, and Japanese.
    • The guards after it took under 20 ms on 180 KB of brief text.
    • briefForWriter has no regex and is linear in the brief.
  • The AI budget. No new call.
    • Start's one hold is charged by what its call used. The cut pass has its own hold, charged the same way.
    • With the flag on, the plan's tokens are charged with the rest. With it off, the tokens are the same as before.
  • Tests.
    • Every new test fails without the change: the functions are new, and the address test fails without briefGiven.
    • The flag-off test compares the write and rewrite prompts with their constants. The suggest prompt is only checked for not having the guardrail (content-writer.test.js:1068). Export SUGGEST_SYSTEM_PROMPT and compare it with toBe as well.
  • Merge.
    • The head (8bbeaa1) merges #1545's squash (dfa51a0) cleanly.
    • Against main (54da3b1), the merge base is dfa51a0 and the diff is these five files only. Main's one newer commit, #1546, is web only, so the merge is clean.
    • In each file the change is this PR's hunks, and nothing of main is dropped.
    • Server only, no migration. Nothing changes on Vercel at merge. At the API deploy with the flag off, only the guards above change.

Earlier open items:

  • Nothing reads leftOut (#1543 item 4): partly done.
    • The writer now says "Keep to one topic; these searches are for another page: …".
    • But buildWritePrompt still lists those fan-outs under "AI searches" (server/src/lib/content-writer.js:345), and the editor's fan-out rules can still ask for an H2 on them. So the writer is told both.
    • Fix:
      • With a version 2 brief, list its leftOut fan-outs apart ("for another page"), or leave them out.
      • Have the web's fan-out rules skip them before the flag goes on.
  • The brief plans links the rules have turned off (#1545 item 3): not touched, and now the agent reads those links.
    • With internal links off, or a page no longer among the brand's top pages, the agent is told of a link it can't keep. A link it writes there is unwrapped, so nothing bad is kept.
    • Fix: read the targets before briefText, and tell the agent only the planned links whose linkKey(url) is in linkAllowList(targets) (content-writer.js:859-861; server/src/lib/content-brief.js:400-405).
  • A renamed H2 leaves a planned link pointing at it (#1546 item 2): now the agent reads it as 'in "Old heading"' and places the link anywhere. That's harmless.
  • A fact's source ref isn't checked to be http(s) (#1540 item 3): still open.
    • The writer takes out only http(s) addresses, so a cited page sent without a scheme would vouch for the numbers in its address.
    • Checking the ref when the brief is built (#1540's fix) closes both.
  • The eval's items (#1540 items 1–2, #1543 items 1–2, #1545 items 1–2): not touched.

Follow-ups (before the flag goes on):

  1. The plan asks a new page for a year, a date and step numbers that the writer isn't given (server/src/lib/content-brief.js:337, :390-391; server/src/lib/content-writer.js:176-178).
    • The year in the title. With the flag on, best-of, buying guide, alternatives and comparison pages are told to put "the year in the title". The writer isn't told the year, and the guard knows only this one (todayText).
      • A model that assumes its training year writes "Best espresso grinders of 2025".
      • The title then comes out "Best espresso grinders of [figure, source]".
    • The "Updated" line. No date is given.
      • "Updated 26 October 2026" becomes "Updated [figure, source] October 2026".
      • The guard doesn't read a month, so a made-up "Updated March 2026" passes.
    • Numbered steps. A new page has bullets only (pageSchema, rendered as a <ul>). So the model types "1." into each bullet, and a tenth step reads "[figure, source]. Adjust".
    • I ran these through sourcedPage to confirm.
    • Fix:
      • Name the year: `the year (${todayText()}) in the title`.
      • Ask for the date as a placeholder: an "Updated [date]" line, for the person to fill. Do the same for datedPoint when no source gives the month.
      • For a new page, word steps as "a list, in order". Or let a section be ordered and render it as an <ol>.
      • Add a test with a best-of brief: the title keeps its year.
  2. Read an address to its end, not to the next space (server/src/lib/content-writer.js:865). This applies with the flag off.
    • \S+ runs on through text with no spaces. In a Japanese key point, "詳細はhttps://acme.jp/priceを参照、3980円から" loses "3980" as well.
      • On a new page, "3980円" becomes a placeholder.
      • On a live page, a suggestion with "3980円" is dropped.
    • It also misses "HTTPS://…" and "www.…" addresses. These still vouch, as on main.
    • Fix:
      • Take the plan's own addresses out where they're written: write each link as its words and H2, and a cited page as "a cited page". That's exact, whatever script a path is in.
      • For an address typed into the brief, stop at whitespace or at the first character outside ASCII. Match either case, and www. too: /(?:https?:\/\/|\bwww\.)[!-~]+/gi. It's linear: 100 KB inputs took under 0.3 ms.
      • Add the Japanese case to the address test.
  3. The no-fabrication eval doesn't see the plan (server/src/scripts/eval-no-fabrication.js:103; server/src/lib/__fixtures__/no-fabrication/guarded.js:21-36).
    • It asks with the new write prompt but with briefText(null, null). So a run with the flag on never shows what the plan adds:
      • facts with no source;
      • proof to gather that Your input doesn't have;
      • an "Updated" line and a year;
      • a planned link with a number in its address.
    • The guards read digits and names only. Written as if it happened, "a customer who caught a shortfall six weeks out" passes them. Only the eval can show whether the model writes it from the plan.
    • Fix (before PR 10 records):
      • With the flag on, give each case, or some of them, a version 2 brief with those parts, as the web's sample has.
      • Have sourcing() read that brief's words without addresses, as writeWithRun does.

@gkhngyk
gkhngyk merged commit c58edb8 into ansvisor:main Oct 26, 2026
6 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