You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Worker: Implement Self-Correction Loop for FAILED Tasks #247
This is the "self-correcting" part of the loop. When a task in 'src/jobs/processGitHubIssueJob.js' or 'src/jobs/processPullRequestCommentJob.js' fails, the worker should not give up immediately.
It should:
Inside the 'catch' block (but before the 'UsageLimitError' check), call the 'analysisService.getExecutionAnalysis' function.
Use the fast analysis model for this (loaded from config).
The 'generateExecutionAnalysisPrompt' needs to be updated to output a specific, parseable suggestion, e.g., in an '' XML tag.
The worker parses this suggestion.
If a concrete suggestion exists (e.g., "Inject file 'X'", "Add 'ls -R' output"), the worker:
a. Gathers the new context.
b. Builds an 'augmentedPrompt'.
c. Calls 'executeClaudeCode' a second time with this new prompt.
If the retry succeeds, the job can proceed.
If the retry also fails, or if no suggestion was provided, then it throws the original error to be marked as 'FAILED'.
This requires refactoring the job files to be able to call the analysis service and potentially re-run the 'executeClaudeCode' step.
This is the "self-correcting" part of the loop. When a task in 'src/jobs/processGitHubIssueJob.js' or 'src/jobs/processPullRequestCommentJob.js' fails, the worker should not give up immediately.
It should:
Inside the 'catch' block (but before the 'UsageLimitError' check), call the 'analysisService.getExecutionAnalysis' function.
Use the fast analysis model for this (loaded from config).
The 'generateExecutionAnalysisPrompt' needs to be updated to output a specific, parseable suggestion, e.g., in an '' XML tag.
The worker parses this suggestion.
If a concrete suggestion exists (e.g., "Inject file 'X'", "Add 'ls -R' output"), the worker:
a. Gathers the new context.
b. Builds an 'augmentedPrompt'.
c. Calls 'executeClaudeCode' a second time with this new prompt.
If the retry succeeds, the job can proceed.
If the retry also fails, or if no suggestion was provided, then it throws the original error to be marked as 'FAILED'.
This requires refactoring the job files to be able to call the analysis service and potentially re-run the 'executeClaudeCode' step.
Suggested Implementation
1. Update src/claude/prompts/promptGenerator.js
Modify 'generateExecutionAnalysisPrompt' to add the structured suggestion output.
// ... existing prompt ...YouranalysismustbeinMarkdownandshouldanswerthefollowing questions:
1.**EfficiencyAnalysis:** ...
2.**PromptImprovement:** ...
3.**ContextInjection:** ...
4.**OverallRating:** ...
**Self-CorrectionSuggestion(MOSTIMPORTANT):**Basedonyouranalysis,providea*single,actionable*suggestionfortheworkerto*immediately*retrythetask.Formatthissuggestioninside '<suggestion>' tags. If no retry is possible, write '<suggestion>none</suggestion>'.
Thesuggestionshouldbeoneof:
***FILE:**'<suggestion>FILE:src/utils/logger.js</suggestion>'(Theworkerwillreadthisfileandinjectit)***COMMAND:**'<suggestion>COMMAND:ls -R</suggestion>'(Theworkerwillrunthiscommandandinjecttheoutput)***PROMPT_CHANGE:**'<suggestion>PROMPT_CHANGE:You must not use 'gitcommit'.</suggestion>'(Theworkerwillappendthistothe*next*prompt)***NONE:**'<suggestion>none</suggestion>'
Example:
<suggestion>COMMAND:ls -R</suggestion>
Activity
integry commentedon Nov 14, 2025
This is the "self-correcting" part of the loop. When a task in 'src/jobs/processGitHubIssueJob.js' or 'src/jobs/processPullRequestCommentJob.js' fails, the worker should not give up immediately.
It should:
a. Gathers the new context.
b. Builds an 'augmentedPrompt'.
c. Calls 'executeClaudeCode' a second time with this new prompt.
This requires refactoring the job files to be able to call the analysis service and potentially re-run the 'executeClaudeCode' step.
Suggested Implementation
1. Update
src/claude/prompts/promptGenerator.jsModify 'generateExecutionAnalysisPrompt' to add the structured suggestion output.
integry commentedon Nov 16, 2025
not relevant for now, but enriching the prompts could be something that would work for all tasks at some point
feat(ai): I fixed both CodeQL alerts (#246 and #247) in the two vendo…
feat(ai): I fixed both CodeQL alerts (integry#246 and integry#247) in…