Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

feat(content): keep the Content Agent's changes small for rules a brand mostly rejects them for (learning B6) (#1686)

Cihane7270dae6430
diff --git a/docs/guides/content-editor.mdx b/docs/guides/content-editor.mdx
index 21e94e014..f2df874ec 100644
--- a/docs/guides/content-editor.mdx
+++ b/docs/guides/content-editor.mdx
@@ -146,7 +146,7 @@ Rebuilding the outline and running the Content Agent use your workspace's monthl
### Apply rules with Agent
-**Apply rules with Agent**, in the Rules tab, asks the Content Agent to suggest changes for the rules the page doesn't meet yet. Its suggestions appear in the page, each with **Accept** and **Reject**, under a bar with **Accept all** and **Reject all**.
+**Apply rules with Agent**, in the Rules tab, asks the Content Agent to suggest changes for the rules the page doesn't meet yet. Its suggestions appear in the page, each with **Accept** and **Reject**, under a bar with **Accept all** and **Reject all**. What you accept and reject teaches it: for a rule whose suggestions this brand has mostly rejected over the last 90 days (at least five decided, on two pages or more, seven in ten rejected), it keeps its changes as small as the rule allows, and while it works its card says which rules. Only its small changes count: a rejected **Rewrite the whole page** doesn't. Quality's **Hand off** isn't affected.
- A decided suggestion can be taken back with **Undo** or **Restore**; **Undo all** brings every one back to review.
- One run makes at most 8 changes. Run it again for the rules still open.
diff --git a/server/src/lib/content-agent.js b/server/src/lib/content-agent.js
index 62557e798..818e98365 100644
--- a/server/src/lib/content-agent.js
+++ b/server/src/lib/content-agent.js
@@ -49,6 +49,8 @@ import { draftLanguage } from './content-language.js';
import { editSpans } from './edit-spans.js';
import { getLanguageName } from './languages.js';
import { PlanLimitError, reserveAiBudget } from './plan-guard.js';
+import { carefulLine, carefulRules } from './content-suggestion-stats.js';
+import { logger } from './logger.js';
/**
* Fix open rules with agent (Content Editor CE-018, spec §8): the Content
@@ -1124,6 +1126,7 @@ export function buildFixPrompt({
linkTargets = '',
sources = '',
handoff = false,
+ careful = '',
}) {
const lines = passages.map((p, i) => {
const locked = lockedKeys.has(passageKey(p.text)) ? ', LOCKED' : '';
@@ -1143,7 +1146,7 @@ Page type: ${pageTypeFormat(draft.page_type)}
Rules the page doesn't meet yet (key: rule — what it asks and how the page reads now):
${rules.join('\n')}
-${over ? `${over}\n` : ''}${handoff ? `${KEEP_PLACEHOLDERS}\n` : ''}${own.length ? `\nThe writer's own rules, to follow in every change:\n${own.join('\n')}\n` : ''}${sources ? `\n${sources}\n` : ''}${linkTargets ? `\n${linkTargets}\n` : ''}
+${over ? `${over}\n` : ''}${careful ? `${careful}\n` : ''}${handoff ? `${KEEP_PLACEHOLDERS}\n` : ''}${own.length ? `\nThe writer's own rules, to follow in every change:\n${own.join('\n')}\n` : ''}${sources ? `\n${sources}\n` : ''}${linkTargets ? `\n${linkTargets}\n` : ''}
The page, passage by passage:
${lines.join('\n')}
@@ -1358,6 +1361,23 @@ async function fixWithRun({
const modelId = contentBriefModelId();
const lockedKeys = new Set(input.locked.map(passageKey));
const ruleKeys = new Set(input.rules.map((r) => r.key));
+ // The rules here people at the brand mostly reject its changes for
+ // (learning B6): kept small, and named on the run's rules step, which the
+ // editor's agent card shows. Apply rules with Agent only: Quality's
+ // hand-off (CE-051), whose card doesn't show it, runs as it was. A read
+ // that fails leaves the run as it was.
+ const careful = handoff
+ ? []
+ : await carefulRules(brandId, { keys: ruleKeys }).catch((err) => {
+ logger.warn(
+ { err: { message: err?.message }, draftId },
+ '[content-agent] decisions not read',
+ );
+ return [];
+ });
+ if (careful.length && run?.steps?.[0]) {
+ run.steps[0] = { ...run.steps[0], careful: careful.map(({ key }) => key) };
+ }
// The data it writes from, numbered, Brief › Your input last (CE-048);
// the numbers it may write unmarked.
await advanceRun(run, 1);
@@ -1458,6 +1478,7 @@ async function fixWithRun({
linkTargets: linkTargetsPrompt(targets, linkKeys),
sources: sourcesPrompt(numbered),
handoff,
+ careful: carefulLine(careful),
}),
abortSignal,
}),
diff --git a/server/src/lib/content-agent.test.js b/server/src/lib/content-agent.test.js
index 21f9a0273..a66a921eb 100644
--- a/server/src/lib/content-agent.test.js
+++ b/server/src/lib/content-agent.test.js
@@ -16,6 +16,8 @@ const reserveAiBudget = vi.fn();
vi.mock('../config/supabase.js', () => ({
default: {
+ // A function's rows, by its name (content_suggestion_decisions, 00367).
+ rpc: async (name) => ({ data: rows[name] ?? [], error: null }),
from: (table) => {
const result = () => ({ data: rows[table] ?? null, error: null });
const chain = {
@@ -1713,6 +1715,48 @@ describe('cleanInsertHtml', () => {
});
describe('fixDraftRules', () => {
+ it('keeps small the changes for rules people at the brand mostly reject, and says so on the run (learning B6)', async () => {
+ rows.content_suggestion_decisions = [
+ // One of this run's rules, mostly rejected.
+ { rule_key: 'faq', accepted: 1, rejected: 7, drafts: 3 },
+ // More rejected, more than five, but not rules here: none takes its place.
+ ...Array.from({ length: 6 }, (_, i) => ({
+ rule_key: `other${i}`,
+ accepted: 0,
+ rejected: 9 + i,
+ drafts: 2,
+ })),
+ // A rule here people take.
+ { rule_key: 'dated', accepted: 6, rejected: 1, drafts: 4 },
+ ];
+ const run = {
+ id: 'r1',
+ steps: [
+ { key: 'read_rules', count: 2 },
+ { key: 'gather_sources', count: 0 },
+ { key: 'write_changes', count: null },
+ ],
+ signal: new AbortController().signal,
+ };
+ runs.startRun = async () => run;
+ generateObject.mockResolvedValue({
+ object: { suggestions: [] },
+ usage: { inputTokens: 900, outputTokens: 20 },
+ });
+ try {
+ await fixDraftRules({ draftId: DRAFT, brandId: BRAND, input: input() });
+ } finally {
+ runs.startRun = null;
+ delete rows.content_suggestion_decisions;
+ }
+ const prompt = generateObject.mock.calls[0][0].prompt;
+ expect(prompt).toContain(
+ 'People at this brand reject most of the changes suggested for these rules: faq (7 of 8 rejected).',
+ );
+ expect(prompt).not.toMatch(/other\d \(/);
+ expect(run.steps[0]).toMatchObject({ key: 'read_rules', careful: ['faq'] });
+ });
+
it("knows the shopping path's prices and names, a product's number only beside its name, and links its pages", async () => {
rows.content_drafts = {
...rows.content_drafts,
@@ -2216,6 +2260,48 @@ describe('Quality’s hand-off (CE-051)', () => {
);
});
+ it('runs as it was for the checks people at the brand mostly reject: Apply rules with Agent only (learning B6)', async () => {
+ rows.content_suggestion_decisions = [
+ { rule_key: 'trust:claimsSourced', accepted: 0, rejected: 9, drafts: 3 },
+ ];
+ const run = () => ({
+ id: 'r1',
+ steps: [
+ { key: 'read_rules', count: 1 },
+ { key: 'gather_sources', count: 0 },
+ { key: 'write_changes', count: null },
+ ],
+ signal: new AbortController().signal,
+ });
+ const handedOff = run();
+ const fixed = run();
+ generateObject.mockResolvedValue({
+ object: { suggestions: [] },
+ usage: { inputTokens: 900, outputTokens: 20 },
+ });
+ try {
+ runs.startRun = async () => handedOff;
+ await fixDraftRules({
+ draftId: DRAFT,
+ brandId: BRAND,
+ input: handoff(),
+ handoff: { origin: 'person' },
+ });
+ // The same rules in Apply rules with Agent are kept small.
+ runs.startRun = async () => fixed;
+ await fixDraftRules({ draftId: DRAFT, brandId: BRAND, input: handoff() });
+ } finally {
+ runs.startRun = null;
+ delete rows.content_suggestion_decisions;
+ }
+ expect(generateObject.mock.calls[0][0].prompt).not.toContain('People at this brand reject');
+ expect(handedOff.steps[0]).not.toHaveProperty('careful');
+ expect(generateObject.mock.calls[1][0].prompt).toContain(
+ 'People at this brand reject most of the changes suggested for these rules: trust:claimsSourced (9 of 9 rejected).',
+ );
+ expect(fixed.steps[0]).toMatchObject({ careful: ['trust:claimsSourced'] });
+ });
+
it('runs an automatic one only on a draft its brand hands off', async () => {
await expect(
fixDraftRules({
diff --git a/server/src/lib/content-suggestion-stats.js b/server/src/lib/content-suggestion-stats.js
new file mode 100644
index 000000000..81bb038aa
--- /dev/null
+++ b/server/src/lib/content-suggestion-stats.js
@@ -0,0 +1,70 @@
+import supabaseAdmin from '../config/supabase.js';
+
+/**
+ * What a brand does with the Content Agent's suggestions, by rule (learning
+ * B6, 00367). Each suggestion names the rules it fixes and keeps whether a
+ * person accepted or rejected it; summed over the last DECISION_WINDOW_DAYS,
+ * a rule whose suggestions people there mostly reject is one the agent
+ * treats carefully: a change only where the rule can't be met without it,
+ * as small as it allows. One brand's own decisions, never another's.
+ */
+
+/** How far back a brand's decisions count: its habits now, not a year ago. */
+export const DECISION_WINDOW_DAYS = 90;
+/** Decided suggestions for a rule before its share means anything. */
+export const CAREFUL_MIN_DECIDED = 5;
+/** Drafts they were rejected on: one Reject all alone doesn't make a habit. */
+export const CAREFUL_MIN_DRAFTS = 2;
+/** The share rejected past which the agent is careful with a rule. */
+export const CAREFUL_REJECT_SHARE = 0.7;
+/** Rules named at most, the most rejected first. */
+const CAREFUL_MAX = 5;
+
+const DAY_MS = 86_400_000;
+
+/**
+ * The rules the brand mostly rejects the agent's suggestions for, each with
+ * its counts, the most rejected first: `[{ key, accepted, rejected, drafts }]`.
+ * `keys`, when given, are the only rules looked at (a run's own), so others
+ * never take their places. Empty when it has decided too few to tell.
+ */
+export async function carefulRules(brandId, { keys, now = new Date(), db = supabaseAdmin } = {}) {
+ const since = new Date(now.getTime() - DECISION_WINDOW_DAYS * DAY_MS).toISOString();
+ const { data, error } = await db.rpc('content_suggestion_decisions', {
+ p_brand_id: brandId,
+ p_since: since,
+ });
+ if (error) throw new Error(`content_suggestion_decisions: ${error.message}`);
+ const wanted = keys ? new Set(keys) : null;
+ return (data ?? [])
+ .map((row) => ({
+ key: String(row.rule_key ?? ''),
+ accepted: Number(row.accepted) || 0,
+ rejected: Number(row.rejected) || 0,
+ drafts: Number(row.drafts) || 0,
+ }))
+ .filter(({ key, accepted, rejected, drafts }) => {
+ const decided = accepted + rejected;
+ return (
+ key &&
+ (!wanted || wanted.has(key)) &&
+ decided >= CAREFUL_MIN_DECIDED &&
+ drafts >= CAREFUL_MIN_DRAFTS &&
+ rejected / decided >= CAREFUL_REJECT_SHARE
+ );
+ })
+ .sort((a, b) => b.rejected - a.rejected || a.key.localeCompare(b.key))
+ .slice(0, CAREFUL_MAX);
+}
+
+/**
+ * What the agent is told about the rules it fixes now that people at this
+ * brand mostly reject its changes for; '' with none.
+ */
+export function carefulLine(careful) {
+ if (!careful.length) return '';
+ const list = careful
+ .map(({ key, accepted, rejected }) => `${key} (${rejected} of ${accepted + rejected} rejected)`)
+ .join(', ');
+ return `People at this brand reject most of the changes suggested for these rules: ${list}. For them, suggest a change only where the rule can't be met without it, and keep it as small as the rule allows: the fewest words, no new section.`;
+}
diff --git a/server/src/lib/content-suggestion-stats.test.js b/server/src/lib/content-suggestion-stats.test.js
new file mode 100644
index 000000000..0ad2c891c
--- /dev/null
+++ b/server/src/lib/content-suggestion-stats.test.js
@@ -0,0 +1,119 @@
+import { readFileSync } from 'node:fs';
+import { describe, expect, it, vi } from 'vitest';
+
+vi.mock('../config/supabase.js', () => ({ default: {} }));
+
+const {
+ CAREFUL_MIN_DECIDED,
+ CAREFUL_MIN_DRAFTS,
+ CAREFUL_REJECT_SHARE,
+ DECISION_WINDOW_DAYS,
+ carefulLine,
+ carefulRules,
+} = await import('./content-suggestion-stats.js');
+
+/** The rules a brand mostly rejects the Content Agent's suggestions for (learning B6). */
+
+const db = (rows) => {
+ const rpc = vi.fn(async () => ({ data: rows, error: null }));
+ return { rpc };
+};
+
+describe('carefulRules', () => {
+ it('names the rules decided often enough and mostly rejected, the most rejected first', async () => {
+ const reads = db([
+ { rule_key: 'faq', accepted: 2, rejected: 8, drafts: 3 },
+ { rule_key: 'tables', accepted: 0, rejected: 12, drafts: 4 },
+ // 7 of 10: just at the share.
+ { rule_key: 'dated', accepted: 3, rejected: 7, drafts: 2 },
+ // Mostly taken.
+ { rule_key: 'answerFirst', accepted: 9, rejected: 1, drafts: 5 },
+ // Too few to tell.
+ { rule_key: 'aiTraces', accepted: 0, rejected: CAREFUL_MIN_DECIDED - 1, drafts: 2 },
+ ]);
+ const now = new Date('2026-10-28T12:00:00Z');
+ expect(await carefulRules('b1', { now, db: reads })).toEqual([
+ { key: 'tables', accepted: 0, rejected: 12, drafts: 4 },
+ { key: 'faq', accepted: 2, rejected: 8, drafts: 3 },
+ { key: 'dated', accepted: 3, rejected: 7, drafts: 2 },
+ ]);
+ expect(CAREFUL_REJECT_SHARE).toBe(0.7);
+ const since = new Date(now.getTime() - DECISION_WINDOW_DAYS * 86_400_000).toISOString();
+ expect(reads.rpc).toHaveBeenCalledWith('content_suggestion_decisions', {
+ p_brand_id: 'b1',
+ p_since: since,
+ });
+ });
+
+ it('takes no one Reject all for a habit: a rule decided on fewer than two drafts', async () => {
+ expect(CAREFUL_MIN_DRAFTS).toBe(2);
+ const reads = db([
+ // Eight rejected at once on one draft.
+ { rule_key: 'faq', accepted: 0, rejected: 8, drafts: 1 },
+ { rule_key: 'tables', accepted: 0, rejected: 6, drafts: 2 },
+ ]);
+ expect((await carefulRules('b1', { db: reads })).map(({ key }) => key)).toEqual(['tables']);
+ });
+
+ it('names five at most, and throws when the decisions can’t be read', async () => {
+ const many = Array.from({ length: 8 }, (_, i) => ({
+ rule_key: `rule${i}`,
+ accepted: 0,
+ rejected: 10 + i,
+ drafts: 2,
+ }));
+ expect(await carefulRules('b1', { db: db(many) })).toHaveLength(5);
+ const failing = { rpc: async () => ({ data: null, error: { message: 'gone' } }) };
+ await expect(carefulRules('b1', { db: failing })).rejects.toThrow('gone');
+ });
+
+ it('looks only at the rules it is given, before the five, so others never take their places', async () => {
+ // Six other keys (an outside agent's suggestions can name any) rejected more.
+ const many = [
+ ...Array.from({ length: 6 }, (_, i) => ({
+ rule_key: `other${i}`,
+ accepted: 0,
+ rejected: 20 + i,
+ drafts: 3,
+ })),
+ { rule_key: 'faq', accepted: 1, rejected: 7, drafts: 2 },
+ { rule_key: 'dated', accepted: 6, rejected: 1, drafts: 2 },
+ ];
+ expect(await carefulRules('b1', { db: db(many), keys: new Set(['faq', 'dated']) })).toEqual([
+ { key: 'faq', accepted: 1, rejected: 7, drafts: 2 },
+ ]);
+ });
+});
+
+describe('content_suggestion_decisions (00367)', () => {
+ const sql = readFileSync(
+ new URL('../../../supabase/migrations/00367_content_suggestion_decisions.sql', import.meta.url),
+ 'utf8',
+ );
+
+ it('counts small changes only, never a whole page rewritten, and the drafts they were rejected on', () => {
+ // The kinds a suggestion is (00217, 00247): every one but 'page'.
+ expect(sql).toMatch(/and s\.kind in \('replace', 'insert'\)/);
+ // Only the drafts with a rejection: a Reject all on one draft and an
+ // Accept on another are still one draft.
+ expect(sql).toMatch(
+ /count\(distinct s\.draft_id\) filter \(where s\.status = 'rejected'\)::integer as drafts/,
+ );
+ expect(sql).toMatch(
+ /returns table \(rule_key text, accepted integer, rejected integer, drafts integer\)/,
+ );
+ });
+
+ it('has the API see it at once', () => {
+ expect(sql.trim().endsWith("notify pgrst, 'reload schema';")).toBe(true);
+ });
+});
+
+describe('carefulLine', () => {
+ it('tells the agent which rules to keep small, and nothing with none', () => {
+ expect(carefulLine([{ key: 'faq', accepted: 2, rejected: 8 }])).toBe(
+ "People at this brand reject most of the changes suggested for these rules: faq (8 of 10 rejected). For them, suggest a change only where the rule can't be met without it, and keep it as small as the rule allows: the fewest words, no new section.",
+ );
+ expect(carefulLine([])).toBe('');
+ });
+});
diff --git a/supabase/migrations/00367_content_suggestion_decisions.sql b/supabase/migrations/00367_content_suggestion_decisions.sql
new file mode 100644
index 000000000..0cb7b142a
--- /dev/null
+++ b/supabase/migrations/00367_content_suggestion_decisions.sql
@@ -0,0 +1,53 @@
+-- ============================================================================
+-- 00367: how a brand decides the Content Agent's suggestions, by rule
+-- (learning B6)
+-- ============================================================================
+-- Each suggestion the agent leaves on a draft (00217) names the rules it
+-- fixes (rule_keys), and keeps whether a person accepted or rejected it. Read
+-- one at a time, nothing learned from them. This sums a brand's decisions
+-- since a day by rule: the agent keeps its changes small for a rule people
+-- there mostly reject (content-suggestion-stats.js). One brand's own
+-- decisions only, read by the API (service role).
+--
+-- Only its small changes count, a passage's words replaced or blocks
+-- inserted: a whole page rewritten to the rules (kind 'page', 00247) names
+-- every rule it was asked for, and one rejected would count against each.
+-- `drafts` is how many drafts a rule's suggestions were rejected on, so one
+-- Reject all on one draft isn't read as a habit, even beside an Accept on
+-- another.
+
+-- A database with an earlier shape of it (a dev database, before review)
+-- takes this one in its place: create or replace can't change its rows.
+drop function if exists public.content_suggestion_decisions(uuid, timestamptz);
+
+create or replace function public.content_suggestion_decisions(
+ p_brand_id uuid,
+ p_since timestamptz
+)
+returns table (rule_key text, accepted integer, rejected integer, drafts integer)
+language sql
+stable
+security invoker
+set search_path to 'public'
+as $$
+ select k.rule_key,
+ count(*) filter (where s.status = 'accepted')::integer as accepted,
+ count(*) filter (where s.status = 'rejected')::integer as rejected,
+ count(distinct s.draft_id) filter (where s.status = 'rejected')::integer as drafts
+ from public.content_draft_suggestions s
+ join public.content_drafts d on d.id = s.draft_id
+ cross join lateral unnest(s.rule_keys) as k(rule_key)
+ where d.brand_id = p_brand_id
+ and s.kind in ('replace', 'insert')
+ and s.status in ('accepted', 'rejected')
+ and s.decided_at >= p_since
+ group by k.rule_key;
+$$;
+
+revoke all on function public.content_suggestion_decisions(uuid, timestamptz) from public, anon, authenticated;
+grant execute on function public.content_suggestion_decisions(uuid, timestamptz) to service_role;
+
+comment on function public.content_suggestion_decisions(uuid, timestamptz) is
+ 'A brand''s accepted and rejected Content Agent suggestions since a day, by rule key, and the drafts they were rejected on; small changes only, not page rewrites (00367, learning B6). Service role only.';
+
+notify pgrst, 'reload schema';
diff --git a/supabase/schema.sql b/supabase/schema.sql
index d9663b7f6..224ea6d98 100644
--- a/supabase/schema.sql
+++ b/supabase/schema.sql
@@ -41860,3 +41860,60 @@ comment on table public.content_shopping_checks is
notify pgrst, 'reload schema';
+-- ─────────────────────────────────────────────────────────────────────────
+-- migrations/00367_content_suggestion_decisions.sql
+-- ─────────────────────────────────────────────────────────────────────────
+-- ============================================================================
+-- 00367: how a brand decides the Content Agent's suggestions, by rule
+-- (learning B6)
+-- ============================================================================
+-- Each suggestion the agent leaves on a draft (00217) names the rules it
+-- fixes (rule_keys), and keeps whether a person accepted or rejected it. Read
+-- one at a time, nothing learned from them. This sums a brand's decisions
+-- since a day by rule: the agent keeps its changes small for a rule people
+-- there mostly reject (content-suggestion-stats.js). One brand's own
+-- decisions only, read by the API (service role).
+--
+-- Only its small changes count, a passage's words replaced or blocks
+-- inserted: a whole page rewritten to the rules (kind 'page', 00247) names
+-- every rule it was asked for, and one rejected would count against each.
+-- `drafts` is how many drafts a rule's suggestions were rejected on, so one
+-- Reject all on one draft isn't read as a habit, even beside an Accept on
+-- another.
+
+-- A database with an earlier shape of it (a dev database, before review)
+-- takes this one in its place: create or replace can't change its rows.
+drop function if exists public.content_suggestion_decisions(uuid, timestamptz);
+
+create or replace function public.content_suggestion_decisions(
+ p_brand_id uuid,
+ p_since timestamptz
+)
+returns table (rule_key text, accepted integer, rejected integer, drafts integer)
+language sql
+stable
+security invoker
+set search_path to 'public'
+as $$
+ select k.rule_key,
+ count(*) filter (where s.status = 'accepted')::integer as accepted,
+ count(*) filter (where s.status = 'rejected')::integer as rejected,
+ count(distinct s.draft_id) filter (where s.status = 'rejected')::integer as drafts
+ from public.content_draft_suggestions s
+ join public.content_drafts d on d.id = s.draft_id
+ cross join lateral unnest(s.rule_keys) as k(rule_key)
+ where d.brand_id = p_brand_id
+ and s.kind in ('replace', 'insert')
+ and s.status in ('accepted', 'rejected')
+ and s.decided_at >= p_since
+ group by k.rule_key;
+$$;
+
+revoke all on function public.content_suggestion_decisions(uuid, timestamptz) from public, anon, authenticated;
+grant execute on function public.content_suggestion_decisions(uuid, timestamptz) to service_role;
+
+comment on function public.content_suggestion_decisions(uuid, timestamptz) is
+ 'A brand''s accepted and rejected Content Agent suggestions since a day, by rule key, and the drafts they were rejected on; small changes only, not page rewrites (00367, learning B6). Service role only.';
+
+notify pgrst, 'reload schema';
+
diff --git a/web/messages/en.json b/web/messages/en.json
index d5bdde846..e7e3c6dee 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -4065,6 +4065,7 @@
}
},
"agentCard": {
+ "careful": "Keeping its changes small for rules people here mostly reject: {rules}.",
"breaks": "would break {names}",
"runFailed": "Content Agent couldn't finish",
"runFailedLine": "Nothing it wrote was kept. Try again; if it fails again, fix what's left yourself.",
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.test.tsx
index 7332bb5e1..143c97e60 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.test.tsx
@@ -465,6 +465,14 @@ describe('AgentCard', () => {
expect(onStop).toHaveBeenCalledTimes(1);
await show(true);
expect(container.querySelector('button')!.disabled).toBe(true);
+
+ // The rules it keeps small, as people at the brand mostly reject them (learning B6),
+ // named as a list: a name may have a comma of its own.
+ run.steps[0] = { key: 'read_rules', count: 14, careful: ['feedMatch', 'unknownRule', 'faq'] };
+ await show(false);
+ expect(container.textContent).toContain(
+ 'Keeping its changes small for rules people here mostly reject: Price, GTIN and stock match the feed and FAQ block.',
+ );
});
it('stops all of its motion with reduced motion, in every state', async () => {
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.tsx
index 8c3ed6c3e..0644462d1 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.tsx
@@ -1,7 +1,7 @@
'use client';
import { useId, useMemo, useState } from 'react';
-import { useLocale, useTranslations } from 'next-intl';
+import { useFormatter, useLocale, useTranslations } from 'next-intl';
import { Check, ChevronRight, User, X } from 'lucide-react';
import { Link } from '@/i18n/navigation';
import { Button } from '@/components/ui/button';
@@ -191,38 +191,52 @@ export function RunSteps({
moving?: boolean;
}) {
const t = useTranslations('contentEditor.editor.agentCard.steps');
+ const tCard = useTranslations('contentEditor.editor.agentCard');
+ const tRules = useTranslations('contentEditor.editor.rules.names');
+ const format = useFormatter();
const shown = shownSteps(run);
+ // The rules it keeps its changes small for (learning B6), by their names.
+ const careful = (run.steps[0]?.careful ?? [])
+ .filter((key) => tRules.has(key))
+ .map((key) => tRules(key));
return (
- <ol className="mt-1 flex flex-wrap items-center gap-1 text-[12px]">
- {shown.map(({ step, index }, i) => {
- const { key, count } = stepMessage(step);
- const done = index < run.step;
- const now = index === run.step;
- return (
- <li key={step.key} className="flex items-center gap-1">
- {i > 0 && (
- <ChevronRight aria-hidden className="h-3 w-3 shrink-0 text-muted-foreground/60" />
- )}
- <span
- aria-current={now ? 'step' : undefined}
- className={cn(
- 'inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5',
- done &&
- 'border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-300',
- now && 'bg-background font-medium text-foreground',
- now && moving && 'relative overflow-hidden',
- !done && !now && 'border-dashed text-muted-foreground',
+ <>
+ <ol className="mt-1 flex flex-wrap items-center gap-1 text-[12px]">
+ {shown.map(({ step, index }, i) => {
+ const { key, count } = stepMessage(step);
+ const done = index < run.step;
+ const now = index === run.step;
+ return (
+ <li key={step.key} className="flex items-center gap-1">
+ {i > 0 && (
+ <ChevronRight aria-hidden className="h-3 w-3 shrink-0 text-muted-foreground/60" />
)}
- >
- {now && moving && <StepSweep />}
- {done && <Check aria-hidden className="h-3 w-3 shrink-0" />}
- {t(key, count === undefined ? {} : { count })}
- {now && moving && <WorkingDots className="ml-0.5" />}
- </span>
- </li>
- );
- })}
- </ol>
+ <span
+ aria-current={now ? 'step' : undefined}
+ className={cn(
+ 'inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5',
+ done &&
+ 'border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-300',
+ now && 'bg-background font-medium text-foreground',
+ now && moving && 'relative overflow-hidden',
+ !done && !now && 'border-dashed text-muted-foreground',
+ )}
+ >
+ {now && moving && <StepSweep />}
+ {done && <Check aria-hidden className="h-3 w-3 shrink-0" />}
+ {t(key, count === undefined ? {} : { count })}
+ {now && moving && <WorkingDots className="ml-0.5" />}
+ </span>
+ </li>
+ );
+ })}
+ </ol>
+ {careful.length > 0 && (
+ <p className="mt-1 text-[11px] text-muted-foreground">
+ {tCard('careful', { rules: format.list(careful, { type: 'conjunction' }) })}
+ </p>
+ )}
+ </>
);
}
diff --git a/web/src/lib/content/agent-runs.test.ts b/web/src/lib/content/agent-runs.test.ts
index 216461485..e79d75d53 100644
--- a/web/src/lib/content/agent-runs.test.ts
+++ b/web/src/lib/content/agent-runs.test.ts
@@ -36,6 +36,15 @@ describe('agent runs', () => {
expect(agentRunFrom(null)).toBeNull();
});
+ it('reads the rules its rules step kept small, keys only, five at most (learning B6)', () => {
+ const steps = [
+ { key: 'read_rules', count: 2, careful: ['faq', 3, '', 'a', 'b', 'c', 'd', 'e'] },
+ { key: 'write_changes', count: null },
+ ];
+ expect(agentRunFrom(row({ steps }))!.steps[0].careful).toEqual(['faq', 'a', 'b', 'c', 'd']);
+ expect(agentRunFrom(row())!.steps[0]).not.toHaveProperty('careful');
+ });
+
it('is under way until it ends, or until a stopped server’s run goes stale', () => {
const run = agentRunFrom(row())!;
const started = Date.parse('2026-10-23T10:00:00Z');
diff --git a/web/src/lib/content/agent-runs.ts b/web/src/lib/content/agent-runs.ts
index 5de541f95..5e5a5cec1 100644
--- a/web/src/lib/content/agent-runs.ts
+++ b/web/src/lib/content/agent-runs.ts
@@ -25,6 +25,11 @@ export interface RunStep {
count: number | null;
/** Why its writing step left nothing (content-agent.js emptyWhy), once done. */
why?: 'none' | 'locked' | 'dropped';
+ /**
+ * Its rules step's rules whose changes people at the brand mostly reject,
+ * kept small (learning B6), as rule keys.
+ */
+ careful?: string[];
}
export type AgentRunKind = 'fix' | 'rewrite' | 'write' | 'brief' | 'handoff';
@@ -61,6 +66,9 @@ export function agentRunFrom(row: Record<string, unknown> | null): AgentRun | nu
...(s.why === 'none' || s.why === 'locked' || s.why === 'dropped'
? { why: s.why }
: {}),
+ ...(Array.isArray(s.careful) && s.careful.some((k) => typeof k === 'string' && k)
+ ? { careful: s.careful.filter((k) => typeof k === 'string' && k).slice(0, 5) }
+ : {}),
},
]
: [],