feat: user hints injection + robustness improvements#78
feat: user hints injection + robustness improvements#78jamoptimus wants to merge 5 commits intosnarktank:mainfrom
Conversation
- Add .ralph-hints.txt file support - Prepend hints to prompt when file exists - Clean up hints file after reading - Works with both amp and claude tools This enables JamBot to inject context into Ralph iterations via !ralph hint command. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add tool validation: check jq/amp/claude exist before running - Track consecutive errors: stop after 3 consecutive tool failures - Capture exit codes instead of silently suppressing with || true - Log errors to progress.txt for debugging - Detect suspiciously short output as potential failures - Clarify edge initialization in flowchart (use explicit false) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add pipefail for proper exit code capture in pipelines - Validate SCRIPT_DIR determination - Use printf instead of echo for HINTS (handles special chars) - Quote variable in string length check - Add error handling for archive mkdir and cp operations - Use parameter expansion instead of sed for branch prefix stripping - Atomic hints file handling (rename-before-read) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add error handling for last-branch file write - Add error handling for progress file initialization (exit on failure) - Quote arithmetic variables in test brackets for robustness Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Greptile OverviewGreptile SummaryAdded user hints injection feature ( Key changes:
The changes improve reliability and enable external control of Ralph during autonomous runs. Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User as External System
participant RalphScript as ralph.sh
participant HintsFile as .ralph-hints.txt
participant AI as AI Tool
User->>HintsFile: Write hints for guidance
RalphScript->>RalphScript: Start iteration loop
RalphScript->>HintsFile: Check if file exists
alt Hints file exists
RalphScript->>HintsFile: Atomic mv to .consumed
RalphScript->>HintsFile: Read .consumed file
RalphScript->>HintsFile: Delete .consumed
RalphScript->>RalphScript: Prepend hints to prompt
end
RalphScript->>AI: Execute with prompt
AI-->>RalphScript: Return output and exit code
alt Tool error
RalphScript->>RalphScript: Increment ERROR_COUNT
RalphScript->>RalphScript: Log to progress.txt
alt ERROR_COUNT >= 3
RalphScript->>RalphScript: Stop execution
end
else Minimal output
RalphScript->>RalphScript: Increment ERROR_COUNT
alt ERROR_COUNT >= 3
RalphScript->>RalphScript: Stop execution
end
else Success
RalphScript->>RalphScript: Reset ERROR_COUNT
alt Output has COMPLETE signal
RalphScript->>RalphScript: Exit with success
else More iterations needed
RalphScript->>RalphScript: Continue loop
end
end
|
ralph.sh
Outdated
| echo "⚠️ Warning: $TOOL returned minimal output (error $ERROR_COUNT of $MAX_CONSECUTIVE_ERRORS)" | ||
| echo "$(date '+%Y-%m-%d %H:%M:%S') - Iteration $i: minimal output warning" >> "$PROGRESS_FILE" | ||
|
|
||
| if [ $ERROR_COUNT -ge $MAX_CONSECUTIVE_ERRORS ]; then |
There was a problem hiding this comment.
Missing $ before ERROR_COUNT in comparison
| if [ $ERROR_COUNT -ge $MAX_CONSECUTIVE_ERRORS ]; then | |
| if [ "$ERROR_COUNT" -ge "$MAX_CONSECUTIVE_ERRORS" ]; then |
Prompt To Fix With AI
This is a comment left during a code review.
Path: ralph.sh
Line: 166:166
Comment:
Missing `$` before `ERROR_COUNT` in comparison
```suggestion
if [ "$ERROR_COUNT" -ge "$MAX_CONSECUTIVE_ERRORS" ]; then
```
How can I resolve this? If you propose a fix, please make it concise.Addresses Greptile review comment - ensures consistent quoting of shell variables in conditional expressions for robustness. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Fixed the variable quoting issue flagged in review - pushed f33c480. Thanks Greptile! |
|
@greptile can you do a final review? The author fixed the variable quoting issue you flagged. |
Summary
This PR adds robustness improvements to ralph.sh and introduces a user hints injection feature for interactive control during autonomous runs.
Changes
New Feature: User Hints Injection
.ralph-hints.txtfile support for injecting context into Ralph iterationsampandclaudetoolsRobustness Improvements
|| truewith explicit error handlingset -o pipefailfor proper exit codesMinor Fixes
printfinstead ofechofor hints (handles special characters)Testing
These changes have been tested with JamBot's Ralph integration, running multiple autonomous coding sessions with hint injection working correctly.
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com