Skip to content

feat(content): read with Claude Haiku 5.5 and write with Claude Sonnet 5.5 - #1743

Merged
gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:feature/content-models-haiku-sonnet
Oct 29, 2026
Merged

gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:feature/content-models-haiku-sonnet

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Product decision (Cihan): the Content Editor reads with Claude Haiku 5.5 and writes with Claude Sonnet 5.5.

Which call goes where (server/src/lib/):

Call Kind Model
content-brief.js Rebuild outline (brief) read Haiku 5.5
content-source-class.js source kind (CE-046) read Haiku 5.5
content-quality-claims.js claims (CE-045) read Haiku 5.5
content-quality-page.js page quality (CE-049/050) read Haiku 5.5
brand-facts.js brand facts (CE-047) read Haiku 5.5
content-agent.js Apply rules with Agent / Quality hand-off write Sonnet 5.5
content-writer.js new page, full rewrite, length trim, live-page suggestions write Sonnet 5.5

The Improve tab, Opportunities' Generate Brief, the opportunity generator, AI Traffic prompt suggestions, Agent Chat and the Action Center task writer are unchanged.

How the model is chosen (contentReadModelId() / contentWriteModelId() in content-brief.js):

  1. CONTENT_READ_MODEL / CONTENT_WRITE_MODEL, if set.
  2. Otherwise anthropic/claude-haiku-5-5 / anthropic/claude-sonnet-5-5 when ANTHROPIC_API_KEY is set.
  3. Otherwise today's model (contentBriefModelId()), so a self-host without an Anthropic key changes nothing.

QUALITY_CHECK_MODEL, if set, still wins for the quality reads. Both new variables are in .env.example and docs/self-host/env-variables.mdx.

Claude 5.5 compatibility:

  • Structured output. @ai-sdk/anthropic 3.0.58 doesn't know the 5.5 models, so it would force a JSON tool with tool_choice: any, which Sonnet 5.5 refuses (400). The new lib/structured-output.js uses native structured output (output_config.format) on Claude calls.
    • That API refuses maxLength, maxItems, minimum/maximum, minItems > 1 and $schema in the schema. Those are stripped for Claude: the meaningful limits move into the field description, and Zod still validates the answer.
  • max_tokens. The SDK drops it to 4,096 for a model it doesn't know, and adaptive thinking (on by default) uses part of it. Claude calls now send 16,000 tokens for reads and 32,000 for writes; the longest page (50k characters) is about 17k tokens as HTML + JSON, plus thinking.
  • No sampling or thinking parameters. No temperature / top_p / top_k (rejected since 2026-10-21) and no thinking parameter are sent. Tests check the request body.
  • Gemini and the other providers are untouched.

Cost metering: improve-cost.js prices Haiku 5.5 at $0.10 / $0.50 per MTok ($0.50 / $2.50 above 100k input tokens) and Sonnet 5.5 at $2 / $10. The AI budget meter counts them correctly; tests included.

Rough cost vs Gemini 3 Flash ($0.50 / $3):

Work Gemini 3 Flash New Change
Brief (8k in / 3k out) $0.013 Haiku $0.002 ~6× cheaper
Page quality read (5k / 1k) $0.0055 Haiku $0.001 ~5× cheaper
Suggestion round (10k / 3k) $0.014 Sonnet $0.050 ~3.5×
Page write (12k / 8k) $0.030 Sonnet $0.104 ~3.5×
Full blog flow (brief + write + 2 rounds + rewrite) ~$0.10 ~$0.31 ~3×

So a Starter $5 budget covers about 16 full flows instead of 40–50, and the $1 trial about 3. Whether the trial budget or the trial's writer model should change is open with the product owner; that will be a follow-up.

For the maintainer

  • Rollout: if ANTHROPIC_API_KEY is set on production, the editor switches to Claude as soon as this deploys. To switch only after a live check, set CONTENT_READ_MODEL and CONTENT_WRITE_MODEL to google/gemini-3-flash-preview on production first.
  • QUALITY_CHECK_MODEL: if it is set on production, the quality reads stay on it.
  • Live check:
    • node src/scripts/eval-brief.js 2 and node src/scripts/eval-no-fabrication.js 2 (a few cents).
    • In the app: Rebuild outline, Start a new page, Apply rules with Agent, Rewrite.
    • Check prompt_improve_usage.model and cost_usd.
  • Timeouts: Sonnet is slower than Flash. The writer has 180 s, the agent and the brief 60 s. A very long page could get close; worth timing before raising effort or limits.
  • Eval judge: the brief eval's default judge is Haiku 4.5. With briefs now written by Haiku 5.5, consider pointing BRIEF_EVAL_JUDGE_MODEL at a non-Claude model.
  • Refusals: the installed AI SDK has no server-side fallbacks for Sonnet 5.5. A refusal ends as a failed, metered run, as today.

Related issue

None (product decision).

Type of change

  • feat — New feature

How to test

  1. Unit: cd server && npx vitest run src/lib/content-brief.test.js src/lib/structured-output.test.js src/lib/improve-cost.test.js (and the content agent, writer and quality tests).
  2. With an Anthropic key on a dev server: Content Editor › Rebuild outline, Start, Apply rules with Agent and Rewrite. Each completes, and prompt_improve_usage shows anthropic/claude-haiku-5-5 for reads, anthropic/claude-sonnet-5-5 for writes, with costs at the new prices.
  3. Without an Anthropic key: the same actions run on the previous model.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • Server: npm run format, npm run lint, npm test pass (280/280 files, 3,933 tests). Web unchanged.
  • Tests added (model choice with/without key and env, native structured output and schema stripping, no sampling or thinking parameters, prices)
  • Docs updated (.env.example, docs/self-host/env-variables.mdx)
  • Live calls with a real Anthropic key: the maintainer's

🤖 Generated with Claude Code

…t 5.5

The Content Editor's AI work now runs on two models: a read model for
analysis (Rebuild outline's brief, Quality's source kinds, claims, page
read and brand facts) and a write model for everything that goes into the
page (pages written or rewritten whole, the cut pass, the Content Agent's
suggestions).

- contentReadModelId / contentWriteModelId: CONTENT_READ_MODEL and
  CONTENT_WRITE_MODEL, else anthropic/claude-haiku-5-5 and
  anthropic/claude-sonnet-5-5 when ANTHROPIC_API_KEY is set, else the
  model the editor ran on before (contentBriefModelId), so self-hosted
  servers without the key are unchanged. QUALITY_CHECK_MODEL still wins
  for Quality's reads. The Improve tab keeps its own model.
- structured-output.js: Claude calls use native structured output
  (output_config.format). @ai-sdk/anthropic 3.0.58 doesn't know the 5.5
  models, so it would force its "json" tool with tool_choice "any" (a 400
  on Sonnet 5.5) and cap max_tokens at 4,096 (thinking is on by default
  and counts toward it). The schema drops the keywords output_config.format
  rejects (lengths, ranges, maxItems, minItems > 1, $schema), tells the
  limits in the description, and zod still validates the answer. Claude
  calls send an explicit maxOutputTokens (16k read, 32k write) and no
  temperature, top_p, top_k or thinking settings.
- improve-cost.js: Haiku 5.5 ($0.10 / $0.50, $0.50 / $2.50 past 100k
  input tokens) and Sonnet 5.5 ($2 / $10), so the AI budget meter charges
  them at their price.
- The brief and no-fabrication evals run the models the product runs.
- Docs: the two env vars in .env.example and self-host env variables.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 88b8b77.

Approve preview

gkhngyk added a commit that referenced this pull request Oct 29, 2026
The Content Editor now writes with Claude Sonnet 5.5 (#1743), about
three times the cost of a page written before; $1 covered about three
full writes. TRIAL_AI_BUDGET_USD goes to 2; a paid plan's own budget is
unchanged.

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>

@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 05c6b3d (take-1743: this PR's head with current main merged in).

What changed on take-1743: the branch conflicted with main in server/src/lib/improve-cost.js. Since this PR was opened, main added prices synced from OpenRouter's catalog (priceFor(modelId, { promptTokens })). The merge keeps that order: the synced price comes first, then the table. The table's long rate now applies inside priceFor, for a call whose prompt passes over, so Haiku 5.5's $0.50 / $2.50 rate holds both with the sync on and with it off. The PR's own price tests cover it, and the 100,001-token case fails without the change.

Model ids. resolveModel sends anthropic/… to the first-party @ai-sdk/anthropic provider, which passes the part after the slash as the model id. So anthropic/claude-haiku-5-5 and anthropic/claude-sonnet-5-5 reach the Messages API as claude-haiku-5-5 and claude-sonnet-5-5, which are the right ids. These calls don't go through OpenRouter.

Metering. The table prices Haiku 5.5 at $0.10 / $0.50 (above 100k input tokens, $0.50 / $2.50) and Sonnet 5.5 at $2 / $10. Those are the list prices, so neither model falls to the $5 / $25 fallback. With the sync on, catalogIds maps the hyphenated ids to OpenRouter's dotted ones (claude-haiku-5.5), so the synced rows win. Holds and usage rows use the same modelId the call runs on, including the length-cut pass.

Structured output. Checked against the installed @ai-sdk/anthropic 3.0.58. With structuredOutputMode: 'outputFormat', it sends output_config.format and no forced json tool. The maxOutputTokens you set is sent as is: the 4,096 clamp only applies to models the SDK knows. No temperature, top_p, top_k or thinking setting is sent.

Overrides. CONTENT_READ_MODEL and CONTENT_WRITE_MODEL win. QUALITY_CHECK_MODEL still wins for Quality's reads. Without ANTHROPIC_API_KEY, every call keeps its previous model. Every generateObject in the Content Editor (brief, source kind, claims, page read, brand facts, agent, writer and cut pass) goes through objectOptions. Nothing outside the Content Editor changes model.

Low, not blocking:

  • At exactly 100,000 prompt tokens, the table charges the base rate (>) while a synced row charges the long rate (>=, OpenRouter's rule). That's a one-token difference.
  • With an Anthropic key set, DEFAULT_SUGGESTION_MODEL no longer picks Quality's model. .env.example says so; docs/self-host/env-variables.mdx could mention it under QUALITY_CHECK_MODEL too.
  • briefSchema's .default('') field and the closed objects can only be confirmed against the real API, in the live check this PR already lists.

Tests (on take-1743):

  • improve-cost, model-price-cache, model-prices, structured-output, content-brief, content-source-class, content-quality-page, content-writer and content-agent: 307/307.
  • Full server suite: 4,037 passed. The 9 files that fail are the 8 Framer files (the framer-api package isn't installed locally) and the timing test in content-people, which passes on its own.
  • eslint and prettier: clean on the touched files.
  • No migration, no PostgREST embed, no new route or server action.

@gkhngyk
gkhngyk merged commit e4c23dc into ansvisor:main Oct 29, 2026
4 of 6 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