Loading...
Loading...
Run tasks until complete with structured completion signals. Auto-invoke when user says "run until done", "keep going until complete", "iterate until finished", "loop mode", "autonomous mode".
npx skill4agent add qf-studio/navigator nav-looploop_mode: true.agent/.nav-config.json{
"loop_mode": {
"enabled": false,
"max_iterations": 5,
"stagnation_threshold": 3,
"exit_requires_explicit_signal": true,
"show_status_block": true,
"iteration_approval": "none",
"periodic_interval": 3,
"never_pause_on_stagnation": false,
"stagnation_diversify_strategy": "combine"
}
}enabledmax_iterationsstagnation_thresholdexit_requires_explicit_signalshow_status_blockiteration_approval"none""strict""periodic"periodic_intervalperiodic_intervaliteration_approval == "periodic"never_pause_on_stagnationtrueAskUserQuestionstagnation_diversify_strategynever_pause_on_stagnation"combine""radical""reread"never_pause_on_stagnation: truemax_iterationspython3 functions/phase_detector.py --inititeration = 1
max_iterations = config.loop_mode.max_iterations or 5
stagnation_threshold = config.loop_mode.stagnation_threshold or 3
hash_history = []
phase = "INIT"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
LOOP MODE ACTIVATED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Task: {TASK_DESCRIPTION}
Max iterations: {max_iterations}
Stagnation threshold: {stagnation_threshold}
Starting iteration 1...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━| Phase | Actions |
|---|---|
| INIT | Load context, understand requirements |
| RESEARCH | Explore codebase, find patterns |
| IMPL | Write code, make changes |
| VERIFY | Run tests, validate functionality, simplify code |
| COMPLETE | All indicators met, ready to exit |
python3 functions/status_generator.py \
--phase "{phase}" \
--iteration "{iteration}" \
--max-iterations "{max_iterations}" \
--indicators "{indicators_json}" \
--state-hash "{current_hash}" \
--prev-hash "{previous_hash}" \
--stagnation-count "{stagnation_count}"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NAVIGATOR_STATUS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Phase: {PHASE}
Iteration: {N}/{MAX}
Progress: {PERCENT}%
Completion Indicators:
[{x or space}] Code changes committed
[{x or space}] Tests passing
[{x or space}] Code simplified
[{x or space}] Documentation updated
[{x or space}] Ticket closed
[{x or space}] Marker created
Exit Conditions:
Heuristics: {MET}/{TOTAL} (need 2+)
EXIT_SIGNAL: {true/false}
State Hash: {HASH}
Previous Hash: {PREV_HASH}
Stagnation: {COUNT}/{THRESHOLD}
Next Action: {NEXT_ACTION}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━config.loop_mode.iteration_approval == "none"| Setting | Behavior |
|---|---|
| Never prompt. Loop continues to Step 4. |
| Prompt after every iteration. |
| Prompt every Nth iteration. N defaults to 3; configurable via |
Question: "Accept iteration {N} and continue?"
Options:
1. [Continue] - Iteration accepted, proceed to next
2. [Adjust] - Provide feedback, incorporate into next iteration
3. [Abort] - End loop, create partial-completion markerstatus: "user_aborted"python3 functions/stagnation_detector.py \
--phase "{phase}" \
--indicators "{indicators_json}" \
--files-changed "{files_json}" \
--history "{hash_history_json}"never_pause_on_stagnationnever_pause_on_stagnation: false━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
STAGNATION DETECTED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Same state detected for {N} consecutive iterations.
Current State:
Phase: {PHASE}
Indicators: {MET}/{TOTAL}
Last Action: {LAST_ACTION}
Possible causes:
1. Blocked by external dependency
2. Unclear requirements
3. Test failures preventing progress
4. Missing context or permissions
Options:
1. [Continue] - Try one more iteration
2. [Clarify] - Explain what's blocking
3. [Abort] - End loop, manual intervention
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━never_pause_on_stagnation: truestagnation_diversify_strategy━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
STAGNATION → AUTO-DIVERSIFY ({STRATEGY})
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Same state for {N} iterations. Auto-recovery: {STRATEGY}
Stagnation counter reset.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━| Strategy | What to attempt next iteration |
|---|---|
| Re-examine partially-met indicators; combine 2 near-miss approaches from previous iterations |
| Discard the current approach; try a substantially different design (different library, different architecture, different algorithm) |
| Re-read the in-scope task doc + relevant system docs; look for a missed signal or constraint |
max_iterationsloop-abortedpython3 functions/exit_gate.py \
--indicators "{indicators_json}" \
--exit-signal "{exit_signal}" \
--require-explicit "{config.exit_requires_explicit_signal}"code_committedtests_passingcode_simplifieddocs_updatedticket_closedmarker_createdIF heuristics >= 2 AND exit_signal == true:
→ EXIT: Task complete
ELIF heuristics >= 2 AND exit_signal == false:
→ CONTINUE: Awaiting explicit completion signal
ELIF exit_signal == true AND heuristics < 2:
→ BLOCKED: Cannot exit with insufficient indicators
ELSE:
→ CONTINUE: More work needed━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
MAX ITERATIONS REACHED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Completed {MAX} iterations without full completion.
Current State:
Phase: {PHASE}
Indicators: {MET}/{TOTAL}
EXIT_SIGNAL: {true/false}
Progress made:
- {PROGRESS_ITEM_1}
- {PROGRESS_ITEM_2}
Options:
1. [Extend] - Add 3 more iterations
2. [Complete] - Accept current state as done
3. [Abort] - Exit without completion
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━{"v":2,"type":"exit","success":true,"reason":"All criteria met"}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
LOOP COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Task: {TASK_DESCRIPTION}
Iterations: {FINAL_COUNT}/{MAX}
Final Phase: COMPLETE
Completion Indicators:
[x] Code changes committed
[x] Tests passing
[x] Code simplified
[x] Documentation updated
[ ] Ticket closed (skipped - no PM tool)
[x] Marker created
Exit Conditions:
Heuristics: 4/5 (passed)
EXIT_SIGNAL: true (passed)
Summary:
- {KEY_CHANGE_1}
- {KEY_CHANGE_2}
- {KEY_CHANGE_3}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━{"v":2,"type":"exit","success":true,"reason":"All requirements met"}pilot-signalreasonv2type"exit"successtruefalsereasondef detect_phase(context):
# COMPLETE: Exit conditions met
if indicators_met >= 4 and exit_signal:
return "COMPLETE"
# VERIFY: Tests running or recently run
if context.tests_running or context.test_exit_code is not None:
return "VERIFY"
# IMPL: Files being modified
if context.files_changed:
return "IMPL"
# RESEARCH: Reading files, searching
if context.files_read and not context.files_changed:
return "RESEARCH"
# INIT: Default starting state
return "INIT"simplification.enabledcode_simplifiedLoop mode config not found in .nav-config.json.
Using defaults: max_iterations=5, stagnation_threshold=3User: "Run until done: add isPrime function with tests"
Iteration 1 (INIT → RESEARCH):
- Read existing math utils
- Found test patterns
Iteration 2 (IMPL):
- Created isPrime function
- Created test file
Iteration 3 (VERIFY):
- Ran tests: PASS
- Committed changes{"v":2,"type":"exit","success":true,"reason":"isPrime function implemented and tests passing"}→ Loop complete in 3 iterationsUser: "Run until done: fix authentication bug"
Iteration 1-3 (IMPL):
- Same changes attempted
- Tests still failing
- State hash unchanged
→ STAGNATION DETECTED
User: "The test needs a mock for the auth service"
Iteration 4 (IMPL):
- Added mock
- Tests pass{"v":2,"type":"exit","success":true,"reason":"Auth bug fixed with mock service"}→ Loop complete in 4 iterations