feat: exit Clone Loop cleanly when Clone signals stop_recommended#11
Merged
Conversation
PR cloneisyou/clone#192 added a `stop_recommended` boolean to the `predict_next_prompt` tool response. The server sets it when Clone predicts a satisfaction-shaped reply (e.g. "good. that's the page.", "ship it") — the user's actual "we're done" voice for an output that meets their bar. Read it in the Stop hook and exit the loop cleanly instead of force- continuing with the prediction as the next prompt. Concretely: Above threshold + stop_recommended=true → no `block()` JSON on stdout → Claude's Stop is allowed through → loop ends. Above threshold + stop_recommended=false → block + inject prediction as next prompt (existing behavior). Below threshold → escalate to human (existing behavior). Gated on the same confidence threshold as continuation. A low- confidence "ship it" is suspicious — could be a hallucinated satisfaction — so we fall through to the existing low-confidence escalation path instead of trusting the signal blindly. State + history: - Loop state file is removed (loop is genuinely done; new session shouldn't try to resume). - A new history record kind `decision: "satisfied"` lands in clone-loop.history.local.jsonl, alongside the existing 'continue' and 'escalate-*' kinds. Tooling that tails the history file should treat 'satisfied' as a clean stop. User-facing: a stderr diagnostic line surfaces what just happened so the user can see why the loop exited at this iteration. Backward-compat: servers that don't return `stop_recommended` (older deploys) leave it undefined → never triggers the early-exit branch → identical behavior to today. Tests: two new cases under stop-hook v2 — one for the satisfaction-exit path, one for the "satisfaction claim ignored when confidence is below threshold" guard. 25/25 pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Companion PR to cloneisyou/clone#192 — read the server's new `stop_recommended` boolean and let the loop actually exit on satisfaction-shaped predictions instead of force-continuing.
Decision flow after this PR
satisfied)Why
Concrete repro from upstream daeun:
```
Iteration 3 : good. that's the page.
Confidence: 0.80 / threshold: 0.3
Status: auto
```
Clone correctly predicted satisfaction. The hook still force-continued the loop because the signal was stuck inside the predicted text — the hook just sees a string and a confidence number, and confidence ≥ threshold means "block Claude's Stop". After the server-side PR (cloneisyou/clone#192), Clone now exposes the satisfaction signal as a structured boolean; this PR is what makes that signal actually exit the loop.
Backward-compat
`stop_recommended` is optional. Servers that don't return it (older deploys) leave it `undefined` → never triggers the early-exit branch → identical behavior to today. Plugin upgrades don't have to be synchronized with server upgrades in either direction.
Test plan
🤖 Generated with Claude Code