fix: Handle API overload errors gracefully
- Detect Claude API 500 Overloaded errors - Continue processing other files on error instead of aborting - Log errors to stderr for visibility This allows commits to succeed even if some AI requests fail due to rate limiting. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
429174f6e4
commit
c231edcd82
|
|
@ -232,6 +232,9 @@ def call_model(model: ModelConfig, prompt: str, cwd: Path) -> str:
|
||||||
# Check if we got output even if returncode is non-zero
|
# Check if we got output even if returncode is non-zero
|
||||||
# (claude CLI returns 1 even on successful prompt responses)
|
# (claude CLI returns 1 even on successful prompt responses)
|
||||||
if result.stdout.strip():
|
if result.stdout.strip():
|
||||||
|
# Check for API errors in the output
|
||||||
|
if "API Error:" in result.stdout and "Overloaded" in result.stdout:
|
||||||
|
raise PatchGenerationError("Claude API is overloaded (500 error) - please retry later")
|
||||||
return result.stdout
|
return result.stdout
|
||||||
|
|
||||||
# Only raise error if we got nothing useful
|
# Only raise error if we got nothing useful
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ def process(repo_root: Path, rules: RulesConfig, model: ModelConfig) -> int:
|
||||||
|
|
||||||
final_instruction = merge_instructions(source_instruction, instruction, append)
|
final_instruction = merge_instructions(source_instruction, instruction, append)
|
||||||
|
|
||||||
|
try:
|
||||||
generate_output(
|
generate_output(
|
||||||
repo_root=repo_root,
|
repo_root=repo_root,
|
||||||
rules=rules,
|
rules=rules,
|
||||||
|
|
@ -80,6 +81,10 @@ def process(repo_root: Path, rules: RulesConfig, model: ModelConfig) -> int:
|
||||||
output_rel=output_rel,
|
output_rel=output_rel,
|
||||||
instruction=final_instruction,
|
instruction=final_instruction,
|
||||||
)
|
)
|
||||||
|
except Exception as e:
|
||||||
|
# Log error but continue processing other files
|
||||||
|
print(f"[runner] error generating {output_rel}: {e}", file=sys.stderr)
|
||||||
|
continue
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue