Repository navigation
feat(content): keep the Content Agent's changes small for rules a brand mostly rejects them for (learning B6) - #1686
Merged
gkhngyk merged 6 commits intoOct 28, 2026
Conversation
…nd mostly rejects them for Learning phase B, B6 (the report's gap 6). Each suggestion the agent leaves names the rules it fixes and keeps whether a person accepted or rejected it (00217), but nothing read the decisions back: the agent kept suggesting the kind of change people there turn down. - 00367 content_suggestion_decisions(brand, since): a brand's accepted and rejected suggestions by rule key (service role only; applied on the dev DB; schema.sql rebuilt). - content-suggestion-stats.js: carefulRules reads the last 90 days and names the rules with at least 5 decided and 7 in 10 rejected, the most rejected first, 5 at most. One brand's own decisions only, never another's. - content-agent.js: for the rules in this run among them, the fix prompt says "People at this brand reject most of the changes suggested for these rules: faq (7 of 8 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…", and the run's rules step keeps `careful`. A read that fails leaves the run as it was. - The editor's agent card shows, under the run's steps: "Kept its changes small for rules people here mostly reject: Price, GTIN and stock match the feed." - The guide says so. Not done: the report also wanted these stats as an input to the brief eval. That eval runs the maintainer's fixtures, and feeding it customers' decisions would use one brand's data beyond it; left out. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s or more, among the run's own rules, and leave Quality's hand-off out Review fixes for B6. - 00367 counts small changes only (kind 'replace' or 'insert'): a page rewrite names every rule it was asked for, and one rejected counted against each. It also returns the drafts a rule's suggestions were decided on, drops an earlier shape of itself first (create or replace can't change its rows), and ends with notify pgrst. schema.sql rebuilt. - carefulRules needs two drafts or more (CAREFUL_MIN_DRAFTS), so one Reject all alone isn't read as a habit, and takes the run's rule keys: it looks only at them before naming five, so other keys (an outside agent's suggestions can name any) never take their places. - Quality's hand-off runs as it was: its card doesn't show the note, so only Apply rules with Agent reads the decisions. - The stats test reads the migration, and states its expected line plainly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the rules named as a list The note shows only while the agent works, so it reads "Keeping its changes small for rules people here mostly reject: …", not "Kept…". The rules are joined with format.list (as the editor's ruleNames does), since a rule's name can have a comma of its own: "Price, GTIN and stock match the feed and FAQ block". Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ns, small changes only, in Apply rules with Agent The decisions are read per brand, not per workspace; a rule needs them on two pages or more; a rejected page rewrite doesn't count; the card names the rules while the agent works; and Quality's Hand off isn't affected. 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 |
9 of 12 tasks
# Conflicts: # supabase/schema.sql
gkhngyk
approved these changes
Oct 28, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good with 5961372: drafts counts only the drafts a rule's suggestions were rejected on, so one Reject all can't make a rule careful. 00367 is applied to production. The follow-ups (a version restore counting as rejections, an index on decided_at) stay open.
gkhngyk
added a commit
that referenced
this pull request
Oct 28, 2026
… it changes it (learning B5, part 3) (#1699) * feat(content): keep the Content Agent's changes small for rules a brand mostly rejects them for Learning phase B, B6 (the report's gap 6). Each suggestion the agent leaves names the rules it fixes and keeps whether a person accepted or rejected it (00217), but nothing read the decisions back: the agent kept suggesting the kind of change people there turn down. - 00367 content_suggestion_decisions(brand, since): a brand's accepted and rejected suggestions by rule key (service role only; applied on the dev DB; schema.sql rebuilt). - content-suggestion-stats.js: carefulRules reads the last 90 days and names the rules with at least 5 decided and 7 in 10 rejected, the most rejected first, 5 at most. One brand's own decisions only, never another's. - content-agent.js: for the rules in this run among them, the fix prompt says "People at this brand reject most of the changes suggested for these rules: faq (7 of 8 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…", and the run's rules step keeps `careful`. A read that fails leaves the run as it was. - The editor's agent card shows, under the run's steps: "Kept its changes small for rules people here mostly reject: Price, GTIN and stock match the feed." - The guide says so. Not done: the report also wanted these stats as an input to the brief eval. That eval runs the maintainer's fixtures, and feeding it customers' decisions would use one brand's data beyond it; left out. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): weigh only a brand's small changes decided on two drafts or more, among the run's own rules, and leave Quality's hand-off out Review fixes for B6. - 00367 counts small changes only (kind 'replace' or 'insert'): a page rewrite names every rule it was asked for, and one rejected counted against each. It also returns the drafts a rule's suggestions were decided on, drops an earlier shape of itself first (create or replace can't change its rows), and ends with notify pgrst. schema.sql rebuilt. - carefulRules needs two drafts or more (CAREFUL_MIN_DRAFTS), so one Reject all alone isn't read as a habit, and takes the run's rule keys: it looks only at them before naming five, so other keys (an outside agent's suggestions can name any) never take their places. - Quality's hand-off runs as it was: its card doesn't show the note, so only Apply rules with Agent reads the decisions. - The stats test reads the migration, and states its expected line plainly. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): say on the agent card it is keeping its changes small, the rules named as a list The note shows only while the agent works, so it reads "Keeping its changes small for rules people here mostly reject: …", not "Kept…". The rules are joined with format.list (as the editor's ruleNames does), since a rule's name can have a comma of its own: "Price, GTIN and stock match the feed and FAQ block". Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(content): say the Content Agent learns from this brand's decisions, small changes only, in Apply rules with Agent The decisions are read per brand, not per workspace; a rule needs them on two pages or more; a rejected page rewrite doesn't count; the card names the rules while the agent works; and Quality's Hand off isn't affected. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): tell the Content Agent what the live page earns before it changes it Learning B5, part 3. The agent fixed a live page's rules without knowing what the page earns as it reads, so a change could take out the very answer AI engines cite, and it never knew which prompts the page lost. - content-live-page.js: the Live page tab's numbers (content_page_impact, 00209, service role) over 30 days against the 30 before: citations, the prompts citing it and the ones it lost (three named, most cited before first), AI visits. Nothing when the page was neither cited nor visited. - Apply rules with Agent on a draft with a source page: the fix prompt says how the page does now, asks to keep the answers, facts and names AI engines may cite and to answer a lost prompt's question where a rule's change can. Quality's hand-off runs as it was; a failed read too. - The run's gather_sources step keeps { days, citations, before, lost }; the agent card says "Keeping what the live page earns: cited 12 times in 30 days (20 before), 2 prompts lost." - The guide says so. Stacked on feature/suggestion-decision-stats (B6, #1686): same prompt slot, run step and card line pattern. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): read the live page at its published address, as the Live page tab does The agent read the live page at the draft's source address only, while the Live page tab reads the address the draft was published at first. On a draft published elsewhere and taken back to Draft, the agent was told about another page than the one the tab shows. - fixDraftRules reads published_url too and asks content_page_impact for published_url ?? source_url. - The test supabase records what each function was sent; the B5 test checks the brand, the page and the 30 days. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(content): cover the live page's read, its hand-off and a failed read - Quality's hand-off neither reads the live page nor is told about it, while Apply rules with Agent on the same page is (B6's hand-off test's twin). - A live page read that fails leaves the run as it was: no line in the prompt, nothing on its sources step, its suggestions kept, a warning logged. - readLivePage: what it sends content_page_impact (the brand, the page, 30 days or the window given), the three lost prompts it names (most cited before first, the count past them), nothing without a page or with nothing to tell, and the error it throws. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(content): give the agent card's live page line its own comment B6's comment on the careful rules sat above the live page's line; the live page now comes after them, with a comment of its own. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): write the live page's earlier citations with thousands separators The agent card wrote the citations of the last 30 days through plural's #, "1,500", and the 30 before as they came, "1200". {before, number} writes both alike. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): name the live page on the agent card only when AI answers cited it A page with AI visits but no citations in either window put "cited 0 times in 30 days (0 before)" on the agent card. Its sources step keeps the live page only when it was cited now or before; the agent is still told of its visits. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): tell the Content Agent "1 time" and "1 AI visit", not "1 times" The live page line counted citations and AI visits in the plural whatever their number; one is now said as one, as the prompts already were. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(content): say Quality's Hand off is affected by neither of Apply rules with Agent's lessons The sentence came between what the agent learns from the brand's decisions and what it is told of the live page; at the paragraph's end it covers both. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content-agent): count only the drafts a rule's suggestions were rejected on * fix(content-agent): quote each lost prompt on one line, cut to 300 characters --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
7 of 12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Agentic learning, B6: the Content Agent keeps its changes small for rules a brand mostly rejects.
Each suggestion the agent leaves on a draft names the rules it fixes, and keeps whether a person accepted or rejected it. Until now, nothing was learned from those decisions.
Migration 00367:
content_suggestion_decisions(p_brand_id, p_since). It returns one brand's accepted and rejected suggestions since a given day, by rule key, plus the number of drafts the suggestions were decided on.kind in ('replace', 'insert'). A whole page rewritten to the rules (kind 'page') names every rule it was asked for, so one rejected rewrite would count against all of them.drop function if existscomes first, because the review changed its return shape on dev. Ends withnotify pgrst.carefulRules(content-suggestion-stats.js). A rule is "careful" when, over the last 90 days, all of these hold:The run's own rules are filtered first, then sorted and capped at 5. Only the brand's own decisions are used; nothing crosses brands. That's the user's decision.
content-agent.js.read_rulesstep recordscareful.Web. While the agent runs, its card says: "Keeping its changes small for rules people here mostly reject: Price, GTIN and stock match the feed and FAQ block." Rule names are joined with
Intllist formatting, because some names contain commas.Docs:
content-editor.mdx.Deliberately not done: feeding these decisions into the brief eval. The eval runs on the maintainer's fixed samples, and putting customers' decisions there would use one brand's data for others.
Known noise (follow-up): suggestions auto-rejected when a version is restored from History, and suggestions left by an MCP outside agent, both count as decisions. No column tells them apart yet.
Where people see it: Content Editor › Rules › Apply rules with Agent, on the agent card while it runs. The line only appears once a brand has enough rejections. The local demo brand has no decisions, so it was checked by tests.
Merge note: independent of the learning Phase A stack. Merged with it, only
supabase/schema.sqlconflicts; re-runbash supabase/build-schema.shto resolve it.Related issue
Agentic learning report, Phase B (B6). No GitHub 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
select * from content_suggestion_decisions('<brand>', now() - interval '90 days');to get rule keys with accepted, rejected and drafts.cd server && npx vitest run src/lib/content-suggestion-stats.test.js src/lib/content-agent.test.jscd web && npx vitest run "src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.test.tsx"Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Full checks at 9661462:
npm test(noSUPABASE_*env, as in CI): 3,345 tests passed.content-agent.test.jsandcontent-people.test.jstimed out under load; each passed alone (102/102, 32/32).vitest(443 files, 4,337 tests) and build: all pass.A pre-push review was run, and its findings are fixed (0bc6ec1, 8f430e1, 9661462). The first commit's message still quotes the card's old wording ("Kept its changes small…"); it is "Keeping…" now. 00367 is applied on the dev database.
🤖 Generated with Claude Code