Skip to content

fix(content): no random agent failures, a run still finishing isn't called failed, and fan-out rules match real headings - #2390

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/content-agent-reliability-fanouts
Nov 13, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/content-agent-reliability-fanouts

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Fixes three Content Editor problems:

  • C1: "Content Agent couldn't finish · Nothing it wrote was kept" showed up at random. The suggestions schema still made zod enforce a maximum of 8 items, even though the model is only told that limit. So an answer with 9 or more suggestions threw NoObjectGeneratedError, and the whole run was lost. keepSuggestions already keeps only the first 8.
  • C2: When a run's answer was lost on the way back, the editor waited only 90 s from the request before calling it failed. A run can take 60 s for the model plus up to 90 s for the fact lookup, so a run that was still working was reported as failed.
  • E1/E3: The fan-out rules (Use top fan-outs as H2s, Use fan-outs in FAQ questions) missed headings people had accepted. For example, "measuring" didn't match "measure", "AI" was dropped, and with three key words one miss failed the match. The Rules tab also didn't say which fan-outs were still missing.

The owner allowed the changes in the editor folder for this work.

Changes

  • Server, suggestions schema: the array no longer has a zod max. The limit is still told to the model in the description ("at most 8 items"), and keepSuggestions trims the answer to 8.

  • Editor, lost answer:

    • It now waits at least 180 s after the answer was lost, instead of 90 s after the request.
    • While the outcome is unknown, the agent card says "Still finishing…".
    • If the outcome is still unknown when the wait ends, a neutral toast says the agent is still finishing and the page can be opened again later. Over an earlier batch, the card keeps saying "Still finishing…".
    • "Couldn't finish" now shows only when the run's row says it failed.
  • Fan-out matching: a new matcher, lib/content/fanout-match.ts, is used only by carries() for the fanoutH2 and fanoutFaq rules. It adds:

    • light stemming (-ing, -ed, -es, -s, -ly, plus "use"/"using" and "strategy"/"strategies");
    • two-letter acronyms written in capitals ("AI", "UX");
    • a match when all but one key word is present, or when at least 75% are, whichever is more lenient, for fan-outs of 3 or more key words.

    Known trade-off: with three key words, two are enough, so "home espresso grinder" would also count an H2 "Home espresso machines". Leaning lenient here stops the rules from staying at 0 on headings people accepted.

    The shared wordsOf is unchanged; its stop-word list is now exported so the matcher can use it.

  • Rules tab: the fanoutH2 and fanoutFaq rows list the fan-outs still missing: the first three, then "+N more". This is a small, local change in RuleRow.

  • Strings: the new strings are in web/messages/en.json.

  • Help: "Write to the Content Editor rules" now explains the missing fan-out list, how a heading counts as using a fan-out, and "Still finishing…". The Help index is regenerated.

How to test

  1. 9 or more suggestions:
    • Run server tests content-agent and structured-output.
    • An answer with 9 suggestions passes the schema, and the run keeps 8.
  2. Lost answer:
    • In the editor, make fixDraftRules time out on the way back. One way is to throttle the network so the server action call is cut off.
    • The card says "Still finishing…" while it waits.
    • If the batch lands within 3 minutes, it is shown.
    • Otherwise a neutral "still finishing" toast shows, never "couldn't run".
    • A run whose row says failed still shows "Content Agent couldn't run".
  3. Fan-outs:
    • Keep a fan-out such as "how to measure ai overviews" in Sources.
    • Add the H2 "Measuring AI Overviews". The "Use top fan-outs as H2s" rule counts it.
    • With no H2s, the rule's row lists the missing fan-outs ("Still to use: “…”, “…”, “…” +N more").
    • An unrelated H2 doesn't count.

Checks

  • Web typecheck: passes.
  • ESLint and Prettier on the changed files: pass. The only ESLint warning is an existing one in page.test.tsx, on a line this change doesn't touch.
  • Web tests for src/lib/content, the editor folder, use-server-exports and Help: 131 files, 1747 tests, all pass.
  • The other tests that read rule checks (Chat page tools, MCP content package, content components): 19 files, all pass.
  • Server tests content-agent and structured-output: 123 tests, all pass.
  • editor-eval (it uses the schema): passes.
  • No migrations, lockfile changes or new dependencies.

Generated by Claude Code

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

LGTM. Small follow-up: when the outcome comes back null after FIX_WAIT_MS, stillFinishing stays true with no further poll, so a run that really failed shows 'Still finishing…' until reload.

@gkhngyk
gkhngyk merged commit 7975c89 into ansvisor:main Nov 13, 2026
13 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.

3 participants