Skip to content

sync: cherry-pick upstream English-only report enforcement#2

Open
lilubot wants to merge 1 commit intomainfrom
feat/upstream-sync-think-fix
Open

sync: cherry-pick upstream English-only report enforcement#2
lilubot wants to merge 1 commit intomainfrom
feat/upstream-sync-think-fix

Conversation

@lilubot
Copy link
Copy Markdown
Owner

@lilubot lilubot commented Mar 29, 2026

Cherry-picks missing upstream commit 313fe64 — forces English-only output in report agent, removes Chinese language fallback from prompts.

Also confirms <think> tag stripping + markdown code fence cleanup already present from prior i18n work.

Co-Authored-By: Nova nova@nova.ai

Summary by Sourcery

Enforce English-only generation for report agent outputs and examples, removing previous Chinese language fallback behavior.

New Features:

  • Add explicit instructions that all report outlines and final answers must be written in English, regardless of source material language.

Enhancements:

  • Update language consistency guidelines and example content in report prompts to require translating any non-English tool output into fluent English.

Summary by CodeRabbit

  • Bug Fixes
    • Report generation now consistently produces all content in English, with automatic translation of any non-English information.
    • Chat responses now reliably respond in English only.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 29, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Enforces English-only behavior for the report agent by updating language-related prompt instructions and examples, removing prior Chinese-language fallback and ensuring responses and report structure are always generated in English.

Flow diagram for language handling in report_agent prompts

flowchart TD
  A[Start report generation] --> B[Load report_agent prompt templates]
  B --> C[Set outline_instruction: report MUST be in English]
  C --> D[Set language_consistency_rule: ALWAYS write in English]
  D --> E[Set rule: translate any non-English tool content to fluent English]
  E --> F[Set answer_style: ALWAYS respond in English]
  F --> G[Agent calls LLM with English-only instructions]
  G --> H{Does tool-returned content contain non-English text?}
  H -->|Yes| I[Translate content to English before including in report]
  H -->|No| J[Use content directly in English]
  I --> K[Compose full report in English]
  J --> K[Compose full report in English]
  K --> L[Return English-only report to user]
  L --> M[End]
Loading

File-Level Changes

Change Details Files
Tighten report outline prompt to require English-only output.
  • Add explicit requirement that the entire report outline (title, summary, section titles, descriptions) must be in English.
  • Clarify that no Chinese or other languages may be used in the outline.
backend/app/services/report_agent.py
Update main report-generation prompt to enforce English-only reports and translation behavior.
  • Replace previous language-consistency rules that allowed Chinese reports with new rules requiring the report be written in English regardless of source language.
  • Specify that any non-English tool output must be translated into fluent English before inclusion, covering both body and quoted text.
  • Explicitly forbid switching to Chinese or other languages mid-report.
  • Refresh the correct example section content to use an English regulatory/industry scenario instead of the prior Chinese social-media scenario.
backend/app/services/report_agent.py
Enforce English-only responses in answer style instructions.
  • Add an instruction that the agent must always respond in English, regardless of source or report language.
backend/app/services/report_agent.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 29, 2026

📝 Walkthrough

Walkthrough

This pull request updates prompt templates in the report agent service to enforce English-only output requirements. Language-consistency rules that previously allowed or required Chinese translation based on source language are replaced with explicit instructions mandating all reports be written in English, with non-English tool-returned content translated before inclusion.

Changes

Cohort / File(s) Summary
Report Agent Prompts
backend/app/services/report_agent.py
Modified report outline and section-generation prompt templates to mandate English-only output. Replaced conditional translation rules with explicit requirement to translate non-English content to English before inclusion. Added "ALWAYS respond in English" constraint to chat prompt. Updated example text in prompts to illustrate different domain (regulatory/corporate strategy).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit's ode to clarity:
Words in English, crisp and bright,
No more mixed tongues in the night,
Reports now shine in unified speech,
One clear language, within reach! 🌙✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'sync: cherry-pick upstream English-only report enforcement' directly and specifically describes the main change: enforcing English-only output in the report agent by cherry-picking an upstream commit.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/upstream-sync-think-fix

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The English-only constraint is now specified in multiple prompt sections; consider centralizing this requirement or referencing a single shared constant to avoid future divergence between templates.
  • Since the behavior is now hard-coded to English regardless of source language, confirm that any upstream configuration or runtime options for report language are either removed or clearly ignored to prevent confusing or conflicting settings.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The English-only constraint is now specified in multiple prompt sections; consider centralizing this requirement or referencing a single shared constant to avoid future divergence between templates.
- Since the behavior is now hard-coded to English regardless of source language, confirm that any upstream configuration or runtime options for report language are either removed or clearly ignored to prevent confusing or conflicting settings.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the report_agent.py service to enforce English-only output for all generated reports and agent responses. The changes modify prompt templates to explicitly prohibit the use of Chinese or other languages, requiring that all content, including translations of tool-returned data, be written in English. The provided examples within the prompts have also been updated to align with this new requirement. I have no feedback to provide as there were no review comments.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
backend/app/services/report_agent.py (2)

1548-1555: ⚠️ Potential issue | 🟡 Minor

Minor: Duplicate comment lines in docstring.

Lines 1549-1555 contain duplicate lines in the docstring describing the file structure. This appears to be a copy-paste artifact.

Proposed fix
         """
         Generate complete report (realtime output per section)
         
         File structure:
-        File structure:
         reports/{report_id}/
             outline.json    - Report outline
             progress.json   - Generation progress
             section_01.md   - Section 1
             section_02.md   - Section 2
-            section_02.md   - Section 2
             ...
             full_report.md  - Complete report
         
         Args:
-            report_id: Report ID (optional, auto-generate if not provided)
             report_id: Report ID (optional, auto-generate if not provided)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/app/services/report_agent.py` around lines 1548 - 1555, Remove the
duplicated lines in the docstring describing the file structure in
report_agent.py: delete the repeated "File structure:" header and the duplicated
"section_02.md   - Section 2" entry so the docstring lists each file and entry
only once (keep a single "File structure:" and one line per file: outline.json,
progress.json, section_01.md, section_02.md).

1522-1523: ⚠️ Potential issue | 🟡 Minor

Minor: Duplicate/redundant error message assignment.

Line 1522 and 1523 both assign final_answer with nearly identical error messages. The second assignment overwrites the first, making line 1522 dead code.

Proposed fix
         if response is None:
-            final_answer = f"(This section generation failed: LLM returned empty response, please retry later)"
-            final_answer = f"(ThisSectiongeneratefailed: LLM returnedemptyresponse, pleaselaterretry)"
+            final_answer = "(This section generation failed: LLM returned empty response, please retry later)"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/app/services/report_agent.py` around lines 1522 - 1523, The code
assigns final_answer twice (both lines set final_answer to nearly identical
error strings), so remove the redundant assignment and keep a single clear
message; locate the duplicate final_answer assignments in report_agent.py (the
block where final_answer is set after an empty LLM response) and either delete
the second bogus line or replace both with one properly formatted message like
"(This section generation failed: LLM returned empty response, please retry
later)" so only one assignment remains.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@backend/app/services/report_agent.py`:
- Around line 1548-1555: Remove the duplicated lines in the docstring describing
the file structure in report_agent.py: delete the repeated "File structure:"
header and the duplicated "section_02.md   - Section 2" entry so the docstring
lists each file and entry only once (keep a single "File structure:" and one
line per file: outline.json, progress.json, section_01.md, section_02.md).
- Around line 1522-1523: The code assigns final_answer twice (both lines set
final_answer to nearly identical error strings), so remove the redundant
assignment and keep a single clear message; locate the duplicate final_answer
assignments in report_agent.py (the block where final_answer is set after an
empty LLM response) and either delete the second bogus line or replace both with
one properly formatted message like "(This section generation failed: LLM
returned empty response, please retry later)" so only one assignment remains.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9ff29a37-c333-406b-af40-6f237e89bd09

📥 Commits

Reviewing files that changed from the base of the PR and between f47fa5c and b849902.

📒 Files selected for processing (1)
  • backend/app/services/report_agent.py

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