Repository navigation
feat(content): tell the Content Agent what the live page earns before it changes it (learning B5, part 3) - #1699
Merged
gkhngyk merged 17 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]>
… 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, ansvisor#1686): same prompt slot,
run step and card line pattern.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e 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]>
…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]>
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]>
…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]>
…rs 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]>
…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]>
… 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]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
# Conflicts: # supabase/schema.sql
gkhngyk
approved these changes
Oct 28, 2026
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, B5 part 3: the Content Agent is told what the live page earns before it changes it.
Stacked on #1686 (B6). Both change the same places:
buildFixPrompt's parameters and template line,fixWithRun,run.steps,agent-runs.ts,_agent-card.tsx,en.jsonand the samecontent-editor.mdxparagraph. This PR's own commits are afa15c7 and the review fixes after it.content-live-page.jsreads the Live page tab's figures throughcontent_page_impact(00209, service role), for 30 days and the 30 before:It returns null when the page was neither cited nor visited in either window.
content-agent.jsreads this summary only for Apply rules with Agent on a draft of a live page. Quality's Hand off is unchanged.run.steps[1]keepslive: { days, citations, before, lost }.Web. While the agent runs, its card says: "Keeping what the live page earns: cited 12 times in 30 days (20 before), 2 prompts lost."
Pre-push review fixes:
published_url ?? source_url, the address the Live page tab measures. Before, a draft published and then reverted to Draft read its old source address.readLivePage: null, window, lost-prompt order.liveline sits undercareful, with its own comment.{before, number}, so the count reads "1,200" like the other.Safety:
p_brand_idand the brand's own domains, so no other brand's data is read.Follow-ups:
content_page_impact.Where people see it: Content › Editor › a draft optimizing a live page › Rules › Apply rules with Agent: the line on the agent card while it runs. New-page drafts show nothing. No new button. Cost: one paragraph more in the same model call, and one RPC per run.
Related issue
Agentic learning report, phase B (B5). No GitHub issue. Learning stays within one brand.
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
cd server && npx vitest run src/lib/content-agent.test.js src/lib/content-live-page.test.jscd web && npx vitest run "src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_agent-card.test.tsx"The local demo brand has no draft of a live page with impact data, so this was checked by tests.
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Full checks at f592f7a:
npm test(noSUPABASE_*env, as in CI): 248 files, 3,362 tests passed;vitest(443 files, 4,338 tests) and build: all pass.A pre-push review was run, and its findings are fixed.
🤖 Generated with Claude Code