Retry incomplete agent repairs safely
This commit is contained in:
@@ -86,5 +86,5 @@ class AiderAgent:
|
||||
"--edit-format",
|
||||
"diff",
|
||||
"--timeout",
|
||||
"60",
|
||||
"180",
|
||||
]
|
||||
|
||||
@@ -33,6 +33,15 @@ def build_task(report: FailureReport) -> str:
|
||||
response = redact(report.response)
|
||||
error = redact(report.error_message)
|
||||
sql = redact(report.sql_query)
|
||||
tenant_scope = ''
|
||||
if report.context.get('database_type') == 'customer':
|
||||
tenant_scope = """
|
||||
Tenant routing fact:
|
||||
The customer has already selected one tenant database. SQL inside that database must not
|
||||
invent an additional customer discriminator column. Use only columns present in tracked
|
||||
schema/semantics, and fix SQL-generation guidance rather than rewriting one unknown column
|
||||
to another guessed column.
|
||||
"""
|
||||
|
||||
return f"""You are fixing failure report #{report.id} in the Laravel AI Chat repository.
|
||||
|
||||
@@ -68,6 +77,7 @@ Observed error:
|
||||
|
||||
Generated SQL, if relevant:
|
||||
{sql or '[not available]'}
|
||||
{tenant_scope}
|
||||
|
||||
Run focused tests while working. Leave the repository with the fix and regression test applied.
|
||||
"""
|
||||
|
||||
@@ -50,6 +50,18 @@ class AutomationWorker:
|
||||
metadata["changes"] = asdict(summary)
|
||||
policy = evaluate_changes(summary, self.settings, workspace.path)
|
||||
if not policy.allowed:
|
||||
if not summary.files and attempt < self.settings.max_agent_attempts:
|
||||
LOG.warning(
|
||||
"Agent produced no changes for report %s on attempt %s; requesting correction",
|
||||
report.id,
|
||||
attempt,
|
||||
)
|
||||
task = build_retry_task(
|
||||
RuntimeError(
|
||||
"No file changes were applied. Make the smallest concrete code and regression-test edits now."
|
||||
)
|
||||
)
|
||||
continue
|
||||
raise RuntimeError(
|
||||
"Policy rejected changes: " + "; ".join(policy.errors)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user