Skip to content

Commit 0c4f650

Browse files
committed
feat: remove corrective retries, improve prompts
1 parent d0ea80c commit 0c4f650

File tree

1 file changed

+23
-57
lines changed

1 file changed

+23
-57
lines changed

src/orchestration/strategies/doc_review.py

Lines changed: 23 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -146,29 +146,8 @@ async def _wait_and_validate(
146146
report_rel = f"{cfg.report_dir}/raw/REPORT_{page['slug']}__r{r_idx}.md"
147147
ok = _verify_file_in_branch(repo_path, result.branch_name, report_rel)
148148
if not (result.success and result.branch_name and ok):
149-
# One corrective retry with explicit instruction
150-
retry_prompt = _build_reviewer_prompt(
151-
page_title=page["title"],
152-
page_path=page["path"],
153-
report_path=report_rel,
154-
corrective=True,
155-
)
156-
retry_task = {
157-
"prompt": retry_prompt,
158-
"base_branch": base_branch,
159-
"model": cfg.model,
160-
}
161-
retry_key = ctx.key(
162-
"page", page["slug"], f"r{r_idx}", "review", "attempt-2"
163-
)
164-
retry_handle = await ctx.run(retry_task, key=retry_key)
165-
try:
166-
result = await ctx.wait(retry_handle)
167-
except Exception:
168-
return None
169-
ok = _verify_file_in_branch(repo_path, result.branch_name, report_rel)
170-
if not (result.success and result.branch_name and ok):
171-
return None
149+
# No corrective retries; rely on strict prompt to ensure commit
150+
return None
172151

173152
# Schedule validator on the reviewer branch
174153
validator_prompt = _build_validator_prompt(
@@ -207,26 +186,8 @@ async def _await_validator(
207186
try:
208187
vres = await ctx.wait(handle)
209188
except Exception:
210-
# One corrective retry prompting to ensure file commit
211-
corrective_prompt = _build_validator_prompt(
212-
page_title=page["title"],
213-
page_path=page["path"],
214-
report_path=report_rel,
215-
corrective=True,
216-
)
217-
vt = {
218-
"prompt": corrective_prompt,
219-
"base_branch": base_branch,
220-
"model": cfg.model,
221-
}
222-
vkey = ctx.key(
223-
"page", page["slug"], f"r{r_idx}", "validate", "attempt-2"
224-
)
225-
h2 = await ctx.run(vt, key=vkey)
226-
try:
227-
vres = await ctx.wait(h2)
228-
except Exception:
229-
return None
189+
# No corrective retries
190+
return None
230191

231192
ok = _verify_file_in_branch(repo_path, vres.branch_name, report_rel)
232193
if not (vres.success and vres.branch_name and ok):
@@ -368,13 +329,7 @@ def _build_reviewer_prompt(
368329
page_title: str,
369330
page_path: str,
370331
report_path: str,
371-
corrective: bool = False,
372332
) -> str:
373-
corrective_text = (
374-
"IMPORTANT: The required report file was not created previously. Create it at the specified path and commit it in a single commit.\n\n"
375-
if corrective
376-
else ""
377-
)
378333

379334
return (
380335
f"<role>\n"
@@ -450,18 +405,18 @@ def _build_reviewer_prompt(
450405
f"Stop only after: the full page has been read; checks executed; all user-visible defects captured; the report file exists with the exact format; "
451406
f"numbering is continuous; the file is added; and exactly one commit has been made.\n"
452407
f"</stop_conditions>\n\n"
453-
f"{corrective_text}"
408+
f"<commit_requirements>\n"
409+
f"CRITICAL: This run is considered failed unless you add and commit the report file. "
410+
f"Uncommitted workspace changes are ignored by orchestration.\n"
411+
f"- Required file: {report_path}\n"
412+
f'- Commit exactly once after writing: git add {report_path} && git commit -m "doc-review: add {Path(report_path).name}"\n'
413+
f"</commit_requirements>\n"
454414
)
455415

456416

457417
def _build_validator_prompt(
458-
*, page_title: str, page_path: str, report_path: str, corrective: bool = False
418+
*, page_title: str, page_path: str, report_path: str
459419
) -> str:
460-
corrective_text = (
461-
"IMPORTANT: Ensure the refined report file exists at the specified path and commit it in a single commit.\n\n"
462-
if corrective
463-
else ""
464-
)
465420

466421
return (
467422
f"<role>\n"
@@ -511,7 +466,12 @@ def _build_validator_prompt(
511466
f"<persistence>\n"
512467
f"Keep going until all findings are validated or removed, the format is exact, numbering is correct, and the single commit is made.\n"
513468
f"</persistence>\n\n"
514-
f"{corrective_text}"
469+
f"<commit_requirements>\n"
470+
f"CRITICAL: This run is considered failed unless you add and commit the refined report file. "
471+
f"Uncommitted workspace changes are ignored by orchestration.\n"
472+
f"- Required file: {report_path}\n"
473+
f'- Commit exactly once after refining: git add {report_path} && git commit -m "doc-review: refine {Path(report_path).name}"\n'
474+
f"</commit_requirements>\n"
515475
)
516476

517477

@@ -557,6 +517,12 @@ def _build_composer_prompt(inputs: List[Tuple[str, str, str]], report_dir: str)
557517
f"<persistence>\n"
558518
f"Keep going until the final merged report exists at the required path with continuous numbering and the single commit is made.\n"
559519
f"</persistence>\n\n"
520+
f"<commit_requirements>\n"
521+
f"CRITICAL: This run is considered failed unless you add and commit the final report file. "
522+
f"Uncommitted workspace changes are ignored by orchestration.\n"
523+
f"- Required file: {report_dir}/REPORT.md\n"
524+
f'- Commit exactly once after composing: git add {report_dir}/REPORT.md && git commit -m "doc-review: compose final report"\n'
525+
f"</commit_requirements>\n\n"
560526
)
561527

562528
# Concatenate inputs; include a clear, minimal provenance marker before each source

0 commit comments

Comments
 (0)