Skip to content

fix(ralph-loop): require tagged completion promise - #284

Open
abhinavgautam01 wants to merge 1 commit into
cursor:mainfrom
abhinavgautam01:fix/282-require-tagged-completion-promise
Open

fix(ralph-loop): require tagged completion promise#284
abhinavgautam01 wants to merge 1 commit into
cursor:mainfrom
abhinavgautam01:fix/282-require-tagged-completion-promise

Conversation

@abhinavgautam01

@abhinavgautam01 abhinavgautam01 commented Aug 28, 2026

Copy link
Copy Markdown

Closes #282

Summary

  • Extract completion promises only from complete <promise>...</promise> tags.
  • Use printf instead of echo to preserve response text during extraction.
  • Add integration regression tests covering tagged, untagged, malformed, mismatched, empty and whitespace-normalized responses.

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 --check
  • shfmt formatting check
  • bash -n on the Ralph hook and test scripts
  • bash ralph-loop/hooks/tests/capture-response.test.sh
    • All six regression cases passed
  • node scripts/validate-plugins.mjs
    • Result: All 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 -p path could leave the full response as “extracted” promise text on non-matches.

Promise extraction now uses printf (avoids echo mangling) 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.sh with six integration cases: untagged match must not set done, 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.

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.

Ralph Loop accepts an untagged response as a completion promise

1 participant