Fix is_clarification_request to defer to final state marker over embedded AGENT_CLARIFY#280
Closed
wwind123 wants to merge 1 commit into
Closed
Fix is_clarification_request to defer to final state marker over embedded AGENT_CLARIFY#280wwind123 wants to merge 1 commit into
wwind123 wants to merge 1 commit into
Conversation
…en it is the final marker A valid AGENT_STATE, AGENT_PLAN_STATE, or AGENT_PR marker appearing after the last AGENT_CLARIFY now takes precedence, preventing embedded protocol examples in plan prose or code blocks from triggering spurious clarification handling. Fixes #278 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
Author
Fix: AGENT_CLARIFY no longer overrides a valid final state markerRoot cause
Fix
def is_clarification_request(text: str) -> bool:
matches = list(CLARIFY_RE.finditer(text))
if not matches:
return False
last_clarify_pos = matches[-1].end()
remaining = text[last_clarify_pos:]
if STATE_RE.search(remaining) or PLAN_STATE_RE.search(remaining) or PR_RE.search(remaining):
return False
return TrueAcceptance criteria coverage
All 710 existing tests pass; 6 new tests added covering issue #278 shapes. -- Anthropic Claude |
Owner
Author
|
Accidental duplicate of PR #279 |
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.
Summary
is_clarification_request()previously returnedTruefor any response containing<!-- AGENT_CLARIFY -->anywhere, including examples in prose or code blocks.<!-- AGENT_PLAN_STATE: blocking -->but containing a literalAGENT_CLARIFYexample in its body would incorrectly abort the loop as a clarification request.AGENT_STATE,AGENT_PLAN_STATE, orAGENT_PRmarker appears after the lastAGENT_CLARIFYin the text, the state marker takes precedence and the response is not treated as a clarification.Fixes #278
Test plan
test_is_clarification_request_state_marker_after_clarify_wins: plan/PR/coder body with embeddedAGENT_CLARIFYexample followed by a valid footer → not clarification.test_is_clarification_request_clarify_as_final_marker_is_still_detected:AGENT_CLARIFYas the final marker → still a clarification;AGENT_STATEin body thenAGENT_CLARIFYat end → clarification wins.test_is_clarification_request_code_block_example_does_not_trigger:AGENT_CLARIFYin a fenced code block +AGENT_PLAN_STATEfooter → not clarification.🤖 Generated with Claude Code