From 057c78110d14d78de6b22bfd7c739a0600dd4914 Mon Sep 17 00:00:00 2001 From: Christian Meyer Date: Fri, 28 Aug 2026 14:36:27 +0200 Subject: [PATCH] Extend bounded syntax repair retries --- src/lai_automation/config.py | 4 ++-- src/lai_automation/worker.py | 4 +++- tests/test_config.py | 4 +++- tests/test_worker.py | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lai_automation/config.py b/src/lai_automation/config.py index dc69ed8..a994fff 100644 --- a/src/lai_automation/config.py +++ b/src/lai_automation/config.py @@ -105,5 +105,5 @@ class Settings: raise ValueError("FAILURE_DB_PASSWORD is required") if not self.test_database_password: raise ValueError("TEST_DB_PASSWORD is required") - if not 1 <= self.max_agent_attempts <= 3: - raise ValueError("MAX_AGENT_ATTEMPTS must be between 1 and 3") + if not 1 <= self.max_agent_attempts <= 5: + raise ValueError("MAX_AGENT_ATTEMPTS must be between 1 and 5") diff --git a/src/lai_automation/worker.py b/src/lai_automation/worker.py index fe18eb5..c053c2e 100644 --- a/src/lai_automation/worker.py +++ b/src/lai_automation/worker.py @@ -133,7 +133,9 @@ class AutomationWorker: RuntimeError( f"{exception}\n{restored_state} Make smaller edits and run php -l on each " "changed PHP file. Reconstruct the intended application fix from this discarded " - f"patch excerpt, correcting its syntax:\n{discarded_diff}" + "patch excerpt, correcting its syntax. This is a repair-only attempt: preserve the " + "intended behavior, place methods inside their owning class, and do not redesign or " + f"expand the solution:\n{discarded_diff}" ), ) continue diff --git a/tests/test_config.py b/tests/test_config.py index 04a175f..2b65342 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -70,4 +70,6 @@ def test_default_commands_initialize_disposable_laravel_schema(monkeypatch) -> N def test_agent_attempts_are_bounded() -> None: with pytest.raises(ValueError, match="MAX_AGENT_ATTEMPTS"): - settings(max_agent_attempts=4).validate() + settings(max_agent_attempts=6).validate() + + settings(max_agent_attempts=5).validate() diff --git a/tests/test_worker.py b/tests/test_worker.py index fe872b5..4528b9e 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -169,6 +169,7 @@ def test_php_syntax_failure_discards_attempt_before_full_validation() -> None: assert "unexpected token" in worker.agent.run.call_args_list[1].args[1] assert "clean repository" in worker.agent.run.call_args_list[1].args[1] assert "intended fix" in worker.agent.run.call_args_list[1].args[1] + assert "repair-only attempt" in worker.agent.run.call_args_list[1].args[1] workspace.restore_checkpoint.assert_called_once_with(None) worker._run_tests.assert_called_once()