diff --git a/automation/patcher.py b/automation/patcher.py index 543fe21..f8fb3f2 100644 --- a/automation/patcher.py +++ b/automation/patcher.py @@ -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 diff --git a/automation/runner.py b/automation/runner.py index c859dbb..102e49a 100644 --- a/automation/runner.py +++ b/automation/runner.py @@ -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