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
|
||||
# (claude CLI returns 1 even on successful prompt responses)
|
||||
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
|
||||
|
||||
# Only raise error if we got nothing useful
|
||||
|
|
|
|||
|
|
@ -72,14 +72,19 @@ def process(repo_root: Path, rules: RulesConfig, model: ModelConfig) -> int:
|
|||
|
||||
final_instruction = merge_instructions(source_instruction, instruction, append)
|
||||
|
||||
generate_output(
|
||||
repo_root=repo_root,
|
||||
rules=rules,
|
||||
model=model,
|
||||
source_rel=src_rel,
|
||||
output_rel=output_rel,
|
||||
instruction=final_instruction,
|
||||
)
|
||||
try:
|
||||
generate_output(
|
||||
repo_root=repo_root,
|
||||
rules=rules,
|
||||
model=model,
|
||||
source_rel=src_rel,
|
||||
output_rel=output_rel,
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue