Repository navigation
feat(content): say when an agent run stops at its most, and when Length can't fit the rules - #1384
Conversation
A replace on a heading that carried its answer ("What is X? X is …") or a
whole FAQ was flattened into the heading's line. Content Agent and the
editor API now split such a replace: the heading keeps its words and the
answer or blocks become an insert after it, kept together or not at all.
An agent change may not grow an H1 past 70 characters or another heading
past 90 (a long imported heading may still be shortened); both agent
prompts and the MCP description say a heading stays one line, and the
editor won't accept an older suggestion that would glue text into one.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A page's H1 is its title. The editor now makes a second H1 an H2 however it comes (typed, pasted, the HTML view, Add HTML or an agent suggestion), keeping the page's own; Heading 1 is off while the page has one, and says why on hover. A version restored from History and older drafts keep theirs, and a new always-on "One H1 per page" rule flags them. The Content Agent is never asked to fix it (it doesn't change heading levels) and its inserted H1s become H2s. URL import keeps the H1 nearest the article's text, not a logo's or a site name's, and makes the rest H2s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
…nly a real answer Review fixes for ansvisor#1369 (gkhngyk): - the question/answer split runs whenever the passage is a heading, also when blocks follow, and the answer goes first under it (inline answer plus a list, or <h2>Q? A.</h2><p>…); - a heading that fits keeps a subtitle: only an answer that ends a sentence (. ! 。 !) is split off; past the limit the rest always goes; - "?" ends a question only before a space; a full-width "?" with or without one; - the regex has no catastrophic case on long text, and the garbled doc comment in agent-suggestions.ts reads again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ent, count HTML blocks' Review fixes for ansvisor#1370 (gkhngyk): - URL import picks the title's H1 once, before the frame and the root go: the last H1 with words before the text's first paragraph (a byline, date or breadcrumb line doesn't count as one), else the first; the title comes from it, and the root's other H1s become H2s; - New content keeps one H1 in a pasted page, a file or an imported page (oneH1Html in bring(): the first H1 with words stays, others are H2s, empty ones unwrapped); - "One H1 per page" counts H1s with words inside HTML blocks too; - an empty H1 line never counts as the page's H1 in the editor, so it never stays over one with words, and Heading 1 stays on beside it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e draft's sources The agent could never meet the Internal links, Outbound links or Cite sources inline rules: a replace's new words were plain text, inserts took no <a>, and it had nowhere to link to. When one of those rules is asked for, it now gets the brand's own pages (site_pages, the most cited and visited first) and the draft's sources (cited pages, not the brand's or a competitor's, not left out), and may link only to those URLs: any other link is unwrapped, tracking parameters come off. A replace keeps its links beside its words (after_links, 00240); an insert keeps them in its HTML. The editor puts them on as link marks when a suggestion is accepted, takes them off on undo, and shows on the card where each one goes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # server/src/lib/content-agent.js
…esults Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the draft's sources The editor API's suggest_content_changes took no links, so an agent working through MCP could not meet the link rules either. get_content_draft now lists link_targets (the brand's own pages, and the draft's sources without the brand's or a competitor's), and suggest_content_changes keeps a link only to one of those URLs, as the Content Agent does on the server: a replace's links go in after_links, an insert's stay in its HTML, any other link is unwrapped and a link with no words dropped. The targets are read only when a suggestion links. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An Optimize draft pasted, read from its URL or a file started with no prompts, so it had no fan-outs unless AI answers cited that very page, and the fan-out rules read "No fan-outs". It now starts with up to ten of the brand's active prompts its title and headings speak to (60% of a prompt's words and at least two, the most in common first), which the person can leave out in Sources. A draft with no prompts shows "Add prompts" on those rules, opening the Sources tab. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A page brought in to optimize (pasted, imported from its URL or a file, read by Start or by an Action Center task) stores its text length as rules.importLength. Its Length rule aims there (±20%), not at a new page's target for the type, and the Content Agent gets the same aim. My rules still apply to such a draft, but not their Length value; Save as my rules keeps the workspace's value, and the person's own value wins. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…th can't fit the rules A run of Apply rules with Agent leaves at most 8 changes (the API's cap, mirrored as AGENT_RUN_MAX). A full batch now says so in its toast and, once decided with rules still open, in the agent bar: run it again for the rest. The Rules tab warns under Length when the fan-out H2s, FAQ questions and summary the rules still ask for take more text, at their least, than Length allows (+20%), so the person can raise Length or ask for fewer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk Content Agent rule gaps C2: the editor says when an agent run stops at its 8-change cap, and the Rules tab warns under Length when the open structure rules can't fit in it (web only, no migration). Stacked on #1383. The PR body has a table of the four e-commerce page types whose default sets trigger the note — a possible defaults follow-up, your call. |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good. Two low items:
-
The note always names all three parts (
web/messages/en.json:4076).- "The fan-out H2s, FAQ questions and summary these rules still ask for…" shows even when only some of them count. In this PR's own test case (a blog post with no fan-outs), the 850 is only FAQ questions plus the summary, yet the note still names fan-out H2s.
- Fix: say "The sections and questions these rules still ask for take about {need}…". Or pass which parts counted and pick the wording from that.
-
The default e-commerce sets trip the note on a brand's first fan-out. The PR description already lists these.
category_pageandcollection_pageshow it from the first fan-out.sizing_guideshows it from 2 andproduct_pagefrom 3.- So most new drafts of those types will show the amber note on untouched defaults.
- Decide whether to lower those types'
fanoutH2/ FAQ defaults (or raise their Length) here or in a follow-up. Merging as-is means a warning on most such drafts until then.
Checked and fine:
lengthConflict.- Rules that are off, rules with an info status, and rules with values of 0 or less add nothing.
fanoutH2is capped at the fan-outs there are, andfanoutFaqcounts only when there are fan-outs. The FAQ rules share one section throughmax.- When every counted rule is met, the note is quiet. The ceiling is
lengthBand(target).max, and a page brought in (#1383) is measured against its own length.
- Run cap.
AGENT_RUN_MAXmatchesMAX_AGENT_SUGGESTIONS, andkeepSuggestionscaps the rows at 8 even after a split. So the toast's>=and the bar's===agree for Apply rules and Start Agent batches. - UI and i18n. The new keys are in
en.jsonwith ICU numbers. The amber note follows the editor's existing warning colour and has a dark variant, and it shows only while Length is on. - Tests. They cover the estimate, rules off or met, no fan-outs, Length off, the note, and the toast and bar for a full batch vs a batch of 2.
gkhngyk
left a comment
There was a problem hiding this comment.
Re-approving after merging main into the branch. The merge only brings in the squashed parent PR; the tree matches the one tested (web and server tests, typecheck, lint, format).
Summary
The editor now says when an agent run stops at its most, and when the Length rule can't fit what the other rules ask for.
On prod, "Apply rules with Agent" left exactly 8 suggestions on every run, and the same rules stayed open.
MAX_AGENT_SUGGESTIONS). Nothing said so, so the run looked finished.Run feedback
AGENT_RUN_MAX = 8inlib/content/suggestions.tsmirrors the server's cap.Length conflict note
lengthConflict(statuses, fanouts)inrules.tsestimates the least text that the open structure rules need:No migration, no server change.
Note for review: I computed the note against every page type's default set (untouched rules, a page not meeting them yet). Four e-commerce types show it once the brand has a few fan-outs; their default Length is short for 4 fan-out H2s + 5 FAQ questions + a summary:
The other 16 types stay quiet at 0–6 fan-outs. I think the note is right there: those defaults can't all be met. A follow-up could lower those types' fan-out H2 / FAQ defaults or raise their Length. That's a product call, so I left the defaults as they are.
Follow-up idea, not here: the hint is a size check on the batch. A run that splits replaces can reach 8 rows without the model hitting its cap. An exact signal would need the API to return a
fullflag.Related issue
Content Agent rule gaps, item C ("8 per run · run again" and rule conflicts), found by testing on prod on 2026-10-22. No issue.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
There are no AI keys locally, so I checked the bar and the note with a temporary draft holding 8 decided suggestions (deleted afterwards).
Tests:
rules.test.ts:lengthConflict— the estimate, rules off or met, no fan-outs, Length off;_rules-tab.test.tsx: the note, and none with Length off;page.test.tsx: the toast and the bar for a full batch, and nothing for a batch of 2.Checked in the browser at 1024 px, in light and dark themes.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) (0 errors; the 6 warnings are in untouched files, as on main)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Also run:
yarn test(2,870 tests) andyarn build, before the review fixes;🤖 Generated with Claude Code