fix: cycle detection prompts reflection instead of just stopping#80
Merged
Conversation
When loop detection fires, the return message now suggests:
1. Reflect on what you were trying to accomplish
2. Try a completely different approach
3. Invoke 5 Whys if available
The old prompt ("stop repeating, change strategy, finish safely") was
purely defensive — it told the agent what NOT to do but gave no
constructive path. This caused agents like Motley to just panic-retry
harder because the circuit breaker said "stop" not "think."
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
|
Motley's panic retry cycle — the incident that motivated this change (image posted on PR #79): When Motley hit rate limits, the old cycle detection said "stop repeating, change strategy" — but gave no constructive path. Result: panic-retry loop where the only move was "try again harder." The new prompt forces a structured context break: reflect → try differently → invoke 5 Whys. |
Owner
|
oh actually, can we do a warning prior to 10 attempts? and have the warning contain this mitigation |
Tim's feedback: warn with reflection guidance BEFORE the hard stop, not just at the point of termination. Now three tiers: - Streak 3-6: simple "loop detected, paused" message - Streak 7-9: WARNING with countdown + full reflection guidance - Streak 10: hard stop terminates the turn The reflection content (try something different, use 5 Whys) now appears at the warning tier where the agent can still act on it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
|
Done — added a warning tier at streak 7 (e927448). Three tiers now:
The reflection content now appears at streak 7 where the agent can still act on it, rather than only at the point of termination. 197 tests pass. |
strix-tkellogg
pushed a commit
that referenced
this pull request
Apr 11, 2026
Four integration points (cycle detection was PR #80): 1. System prompt: route introspection → 5 Whys when patterns emerge, and route prediction misses to structured reflection 2. Post-turn failure context: when a turn ends with an error or circuit breaker, inject reflection guidance into the next turn's prompt 3. Prediction-review → 5 Whys bridge: SKILL.md now guides agents to decompose surprising misses via 5 Whys instead of just logging false 4. Chat history scan: prediction-review scheduled job now also scans recent chat for corrections, error reactions, and repeated attempts The 5 Whys skill existed but nothing routed agents toward it when failure happened. Now four paths converge on it: introspection findings, prediction misses, circuit breaker events, and chat history patterns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 tasks
jptreen
pushed a commit
to jptreen/open-strix
that referenced
this pull request
Apr 11, 2026
Merged upstream changes: - PR tkellogg#80: Cycle detection prompts reflection instead of just stopping - PR tkellogg#81: Five-whys integration into harness failure paths - PR tkellogg#82: Five-whys chainlink docs - PR tkellogg#83: Phone book → JSONL migration + alias enrichment Conflict resolution: - app.py: Kept both _withhold_final_text (ours) and _last_turn_failure (upstream) - prompts.py: Preserved auto-send model while adding aliases/failure sections - tools.py: Added missing file tools to tools list (read_file, glob_files, edit_file, write_file) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Merged
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
Context
Motley's panic retry cycle (documented in PR #79) is the case study: he had journal, had tools, but when rate-limited his only move was "try again harder" because the circuit breaker just said "stop" not "think."
Changes
open_strix/tools.py: Two string changes to the cycle detection return messages (soft stop at streak threshold, hard stop at streak=10).Test plan
🤖 Generated with Claude Code