Skip to content

fix(content): tell the Content Agent how long an existing page is now, beside its Length - #1627

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/agent-current-length
Oct 28, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/agent-current-length

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

On an existing page, the agent's suggestions were told only the page's Length ("about 3000 characters"), never how long the page already was. A page of 5,353 characters with a Length of 3,000 got suggestions that added more (editor tests, 2026-10-26 and 2026-10-27).

The prompt for an existing page's suggestions (buildWritePrompt with passages) now says how long the page is now (lengthNow). It reads that against the Length's ±20% band, as the editor does:

  • over the band: suggest cuts (repetition, filler, the least useful detail) before anything new, and keep each addition short;
  • under it: add what the questions and rules ask for;
  • within it: keep it about this long.

A new page has no length yet. A page rewritten whole is told its length in its own lines, as before.

Needs the API deploy.

Related issue

None. From Ansvisor’s production test of the Content Editor and Send to CMS (2026-10-27).

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

cd server && npx vitest run src/lib/content-writer.test.js src/lib/content-agent.test.js

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Checked together with the other PRs from the same test (one integration tree of all eleven on main 3f6a4d4):

  • server/: npm run format, npm run lint and npm test (3,349 tests).
  • web/: yarn format, yarn lint (0 errors, the 7 earlier warnings), yarn typecheck, yarn test (4,385 tests) and yarn build.
  • This branch's own tests were also run on it alone.

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits October 28, 2026 00:29
…, beside its Length

Started on an existing page, the agent's suggestions were told only the
page's Length ("about 3000 characters"), never how long the page already
was. A page of 5,353 characters for a Length of 3,000 got suggestions that
added more (editor tests 2026-10-26 and 2026-10-27).

The prompt for an existing page's suggestions (buildWritePrompt with
passages) now says how long the page is now and what that asks of them
(lengthNow), against the Length's ±20% band, as the editor reads it:
- over the band: suggest cuts (repetition, filler, the least useful
  detail) before anything new, and keep each addition short;
- under it: add what the questions and rules ask for;
- within it: keep it about this long.

A new page has no length yet, and a page rewritten whole is told its
length in its own lines, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… is among the rules

With Length off the page keeps its length, as in a whole rewrite and the agent's own line, so its suggestions aren't asked to cut it.
@gkhngyk

gkhngyk commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

I took the review's before-merge item over (c94bc59): the current-length line goes in only when Length is among the rules, as overLengthLine does, with a Length-off test. The length read itself is bounded in #1700, which should go first.

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

Looks good with c94bc59: the current-length line goes in only when Length is among the rules, and the length read it uses is bounded on main since #1700.

@gkhngyk
gkhngyk merged commit b5658da into ansvisor:main Oct 28, 2026
5 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.

2 participants