Skip to content

fix(rewrite): place input text strictly after intensity and style clauses (#337) - #340

Open
poorvith-mp wants to merge 5 commits into
mainfrom
poorvithmp/fix-prompt-intensity-placement-337
Open

poorvith-mp wants to merge 5 commits into
mainfrom
poorvithmp/fix-prompt-intensity-placement-337

Conversation

@poorvith-mp

@poorvith-mp poorvith-mp commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Fixes #337.

What

In �uild_prompt() (service/scripts/rewrite_text.py), ensure that the input {text} is always positioned strictly after all instruction, intensity, and style clauses at the end of the prompt (after \n\n---\n).

Why

When combining a tactic with an intensity level (e.g. paraphrase@0.8) or --style, _intensity_clause and _style_clause were previously appended after {TEXT}. As reported in #337, models would frequently treat the trailing instructions as part of the source content to rewrite or echo meta-commentary back.

Tests

  • Added est_build_prompt_text_always_placed_at_end_after_clauses in ests/test_rewrite_text.py covering all tactics with intensity and style.
  • All existing tests in ests/test_rewrite_text.py pass.

Summary by CodeRabbit

  • Bug Fixes

    • Improved text rewriting prompts so instruction, intensity, and style settings are consistently applied before the input text.
    • Preserved tactic-specific behavior, including special handling for code rewriting.
  • Tests

    • Added coverage to verify that input text consistently appears at the end of generated prompts across supported rewriting tactics.

@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration

Configuration used: Repository: guillaumemeyer/watermarks-remover/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 60038d50-f495-4dca-a723-f156b9620aab

📥 Commits

Reviewing files that changed from the base of the PR and between 4d3bd6d and c2e1ef1.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 6d9bd44a-b990-4839-b77e-6250847c5495

📥 Commits

Reviewing files that changed from the base of the PR and between 81d808d and ef2b74a.

📒 Files selected for processing (2)
  • service/scripts/rewrite_text.py
  • tests/test_rewrite_text.py

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

build_prompt now appends source text after tactic, intensity, and style clauses. Intensity remains excluded for code. A test verifies the ordering for six tactics.

Changes

Prompt placement

Layer / File(s) Summary
Prompt construction and validation
service/scripts/rewrite_text.py, tests/test_rewrite_text.py
build_prompt builds the instruction header without embedded text, adds applicable clauses before the separator, and appends the source text at the end. The test checks this ordering for six tactics and confirms the code intensity exception.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 90bd6

The prompt-placement change correctly keeps rewrite instructions ahead of the source content, with no concrete merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: placing input text after intensity and style clauses in rewrite prompts. It is concise and specific.
Linked Issues check ✅ Passed The change meets the coding requirements in issue #337. build_prompt() now creates tactic prompts with an empty text placeholder, removes the template separator before adding intensity and style cla…
Out of Scope Changes check ✅ Passed The pull request changes only service/scripts/rewrite_text.py and its related test. The test directly verifies the prompt-order objective in issue #337. No unrelated behavior or files are changed.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch poorvithmp/fix-prompt-intensity-placement-337

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@poorvith-mp
poorvith-mp force-pushed the poorvithmp/fix-prompt-intensity-placement-337 branch from ef2b74a to b7eafaa Compare September 13, 2026 02:37
@poorvith-mp
poorvith-mp force-pushed the poorvithmp/fix-prompt-intensity-placement-337 branch from b7eafaa to 73c6c4c Compare September 13, 2026 02:42
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.

Layer B: intensity clause appended after {TEXT} causes models to echo/paraphrase it into the rewrite output

1 participant