fix(ralph-loop): require tagged completion promise - #284
Open
abhinavgautam01 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #282
Summary
<promise>...</promise>tags.printfinstead ofechoto preserve response text during extraction.Why
The previous Perl expression used
-p, which prints the complete response even when the<promise>substitution does not match.As a result, an untagged response that exactly matched the configured completion promise could create the Ralph done flag and prematurely terminate the loop.
The updated extractor prints text only after finding a complete promise tag.
Validation
git diff --checkshfmtformatting checkbash -non the Ralph hook and test scriptsbash ralph-loop/hooks/tests/capture-response.test.shnode scripts/validate-plugins.mjsAll plugins validated successfully.Note
Low Risk
Scoped hook behavior fix with regression tests; only affects when the Ralph loop marks itself done, with stricter (safer) completion detection.
Overview
Fixes a bug where the Ralph afterAgentResponse hook could end the loop when the assistant’s plain text matched
completion_promise, even without<promise>...</promise>tags. The old Perl-ppath could leave the full response as “extracted” promise text on non-matches.Promise extraction now uses
printf(avoidsechomangling) and Perl that only emits inner text when a complete tag pair exists, still trimming and collapsing whitespace before comparing to the configured promise.Adds
capture-response.test.shwith six integration cases: untagged match must not setdone, valid tagged matches (including multiline/whitespace), wrong promise, missing closing tag, and empty input.Reviewed by Cursor Bugbot for commit 91ebae5. Bugbot is set up for automated code reviews on this repo. Configure here.