t247.1: Context-remaining guard in loop-common.sh#987
Conversation
Prevents clean_exit_no_signal retries by detecting context exhaustion before the AI tool exits silently. Four detection heuristics: 1. Iteration threshold (>= 80% of max) 2. Explicit context limit markers in output 3. Empty/near-empty output after first iteration 4. Output shrinkage (< 20% of rolling average) When triggered: emergency commit+push, emit FULL_LOOP_COMPLETE signal, create receipt for audit trail, store memory for pattern tracking. Also adds context guard awareness to re-anchor prompt so the AI tool itself can signal when running low on context.
Ralph is the actual production loop runner. Adds output_sizes_file tracking and loop_context_guard() call after each iteration, matching the integration in loop_run_external(). Uses type-guard pattern consistent with existing ralph code for graceful degradation when loop-common.sh is not loaded.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Tue Feb 10 19:45:48 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|



Summary
Adds a context-remaining guard to
loop-common.shthat detects approaching context exhaustion and proactively emitsFULL_LOOP_COMPLETE+ pushes uncommitted work before the AI tool exits silently. This prevents theclean_exit_no_signalretry pattern that affected 16 tasks (100% eventually succeeded on retry, but each retry wasted ~300s).Changes
New functions in
loop-common.shloop_check_context_exhaustion()— Four detection heuristics:loop_emergency_push()— Commits any uncommitted work and pushes to preserve it before exitloop_emit_completion_signal()— Emits<promise>FULL_LOOP_COMPLETE</promise>to stdout (captured in worker log for supervisor detection)loop_context_guard()— Orchestrates all three: check → push → signal. Returns 0 if guard triggered (caller should exit cleanly).Integration points
loop_run_external()inloop-common.sh— guard check added after each iterationrun_loop_v2()inralph-loop-helper.sh— guard check added after each iteration (this is the production code path)Configurable thresholds (env vars)
LOOP_CONTEXT_ITER_THRESHOLDLOOP_CONTEXT_SHRINK_THRESHOLDLOOP_CONTEXT_SHRINK_MIN_ITERSLOOP_CONTEXT_MIN_OUTPUT_BYTESTesting
typeguards in ralph for graceful degradationTask
Closes t247.1. Part of t247 (reduce clean_exit_no_signal retries).