Skip to content

Translate newsletter article titles and strip publisher suffix - #1051

Merged
kevinhermawan merged 1 commit into
mainfrom
fix/newsletter-article-title-translation
Jul 24, 2026
Merged

Translate newsletter article titles and strip publisher suffix#1051
kevinhermawan merged 1 commit into
mainfrom
fix/newsletter-article-title-translation

Conversation

@kevinhermawan

Copy link
Copy Markdown
Contributor

Summary

Newsletter article titles were copied verbatim from the scraped source, so an English issue could carry a foreign-language headline with its publisher suffix intact (for example Terungkap Efek Suku Bunga BI ke Bank Bikin Kaget - Haluan News). The per-article summarizer now also returns the title, translated into the newsletter's language and stripped of any trailing publisher or site name, and the generator uses that title instead of the raw source string.

Related issues

Closes #1050

Important changes

  • summarize-article.ts: articleSummarySchema now requires a title. The prompt tells the model to translate the article's own title faithfully into English (no paraphrase or summary), keep numbers, tickers, and proper nouns verbatim, pass English titles through unchanged, and drop any trailing - Publisher / | Site / — Outlet suffix.
  • llm-generate-newsletter.ts: the assembled article uses the model's returned title rather than source.title. A title that fails validation after retries drops the article through the existing summary-failure path, so a dirty or untranslated title never ships.

Other changes

  • The Indonesian pass is untouched: it already treats the title as translatable copy, so it inherits the clean English base title and translates it onward.
  • Tests: the summarizer mock now returns a title, and a new case asserts the model's translated title lands in the document instead of the raw source title.

Key files to review

  • apps/mediapulse/agents/content-generation/src/summarize-article.ts - schema field and prompt wording that keeps translation faithful.
  • apps/mediapulse/agents/content-generation/src/llm-generate-newsletter.ts - title now flows from the model through SummaryOutcome into the document.
  • apps/mediapulse/agents/content-generation/src/llm-generate-newsletter.test.ts - provenance assertion for the translated title.

How to test

  1. From apps/mediapulse/agents/content-generation, run npx vitest run src/llm-generate-newsletter.test.ts src/run.test.ts src/translate-newsletter.test.ts.
  2. Generate a newsletter for a ticker whose sources include non-English headlines.
  3. Confirm the English issue shows English titles with no - Publisher suffix, and the Indonesian issue shows Indonesian titles.

Article titles were set verbatim from the scraped source title, so an English newsletter could show a foreign-language headline carrying a publisher suffix like "- Haluan News". The per-article summarizer now also returns the title, translated faithfully into English with any trailing publisher or site name removed, and the generator uses that title instead of the raw source string. The Indonesian pass inherits the clean base title unchanged.
@kevinhermawan
kevinhermawan merged commit c11d9b5 into main Jul 24, 2026
9 checks passed
@kevinhermawan
kevinhermawan deleted the fix/newsletter-article-title-translation branch July 24, 2026 08:37
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.

Translate newsletter article titles and remove publisher suffix

2 participants