sync: cherry-pick upstream English-only report enforcement#2
sync: cherry-pick upstream English-only report enforcement#2
Conversation
…age fallback and examples
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnforces 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 promptsflowchart 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]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
📝 WalkthroughWalkthroughThis 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 | 🟡 MinorMinor: 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 | 🟡 MinorMinor: Duplicate/redundant error message assignment.
Line 1522 and 1523 both assign
final_answerwith 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
📒 Files selected for processing (1)
backend/app/services/report_agent.py
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:
Enhancements:
Summary by CodeRabbit