Skip to content

fix: make validate_repeat_prompt strip/case-insensitive#1774

Open
Chessing234 wants to merge 2 commits into
allenai:mainfrom
Chessing234:fix/validate-repeat-prompt-strip-case
Open

fix: make validate_repeat_prompt strip/case-insensitive#1774
Chessing234 wants to merge 2 commits into
allenai:mainfrom
Chessing234:fix/validate-repeat-prompt-strip-case

Conversation

@Chessing234

@Chessing234 Chessing234 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Strip and lower both sides before startswith, matching IFEvalG.

Test plan

  • Unit tests for leading space and case
  • GPU_TESTS=bypass

Chessing234 and others added 2 commits July 18, 2026 19:33
Match IFEvalG so leading whitespace and case no longer fail the check.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the validate_repeat_prompt function to strip whitespace and perform case-insensitive comparisons, aligning it with IFEvalG, and adds corresponding unit tests. The review feedback suggests removing a redundant bool() cast, adding a test case to verify handling of whitespace in the original prompt, and replacing the placeholder PR number in the changelog.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread CHANGELOG.md
### Removed

### Fixed
- Make `validate_repeat_prompt` strip/case-insensitive (https://github.com/allenai/open-instruct/pull/1774).

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.

medium

This changelog entry contains a placeholder XXXX for the pull request number. Please update it with the actual PR number before merging to ensure the changelog is accurate.

def validate_repeat_prompt(text: str, original_prompt: str) -> bool:
return bool(text.startswith(original_prompt))
"""Match IFEvalG: strip and compare case-insensitively."""
return bool(text.strip().lower().startswith(original_prompt.strip().lower()))

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.

medium

The bool() cast is redundant here since str.startswith() already returns a boolean. Removing it will make the code slightly cleaner.

Suggested change
return bool(text.strip().lower().startswith(original_prompt.strip().lower()))
return text.strip().lower().startswith(original_prompt.strip().lower())

Comment on lines +44 to +49
[
("exact", "Hello world answer", "Hello world", True),
("leading_space", " Hello world answer", "Hello world", True),
("case", "HELLO world answer", "Hello world", True),
("missing", "Something else", "Hello world", False),
]

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.

medium

The new tests cover changes to text well. To make the test suite more comprehensive, consider adding a test case to verify that original_prompt with leading or trailing whitespace is handled correctly by strip(). For example: ('prompt_with_space', 'Hello world answer', ' Hello world ', True)

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.

1 participant