fix: give final acceptance a shared retry budget and diagnostics
This commit is contained in:
1 parent
50638d4130
commit
32441e79c4
18 files changed
+779
-40
No files matched your search
@@ -51,6 +51,7 @@ from artemis.context import ArtemisContext
|
||||
from artemis.data_engine.context_vars import CURRENT_TRACE_ID
|
||||
from artemis.data_engine.trace import trace, trace_langchain_tool
|
||||
from artemis.llm.parser import extract_thinking_tags
|
||||
from artemis.llm.final_review import final_review_stage
|
||||
from artemis.llm.structured import content_to_text
|
||||
from artemis.services.llm import acomplete, get_llm, invoke_llm_with_timeout_message
|
||||
from artemis.tools.history import get_history_tools
|
||||
@@ -499,7 +500,9 @@ def _completed_text_report(response, check_items) -> CheckReport | None:
|
||||
|
||||
async def _structured_report(llm, messages, check_items=()) -> CheckReport:
|
||||
if messages and (report := _completed_text_report(messages[-1], check_items)) is not None:
|
||||
final_review_stage("validating_verdict")
|
||||
return report
|
||||
final_review_stage("structuring_verdict")
|
||||
structured_llm = llm.with_structured_output(CheckReport)
|
||||
# A conversation must end with a user turn: Gemini rejects requests whose
|
||||
# last message is the model's own answer ("Requests ending with a model
|
||||
@@ -575,6 +578,7 @@ async def _run_check_loop(
|
||||
|
||||
report: CheckReport | None = None
|
||||
for i in range(max_iterations):
|
||||
final_review_stage("reviewing_evidence", iteration=i + 1)
|
||||
if i == max_iterations - 1:
|
||||
messages.append(
|
||||
HumanMessage(
|
||||
@@ -594,6 +598,7 @@ async def _run_check_loop(
|
||||
break
|
||||
|
||||
messages.append(response)
|
||||
final_review_stage("reading_evidence")
|
||||
for tc in response.tool_calls:
|
||||
tool_name = tc["name"].split(":")[-1] if ":" in tc["name"] else tc["name"]
|
||||
args = dict(tc["args"])
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"""Flash's exit-only acceptance check uses the same read-only Checker as Pro."""
|
||||
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from artemis.agents.checker.checker import run_final_check
|
||||
from artemis.context import ArtemisContext
|
||||
from artemis.llm.diagnostics import final_review_error_text
|
||||
from artemis.graph.checkpoints import (
|
||||
RunOutcome,
|
||||
TestSummary,
|
||||
@@ -14,6 +14,7 @@ from artemis.graph.checkpoints import (
|
||||
write_run_outcome,
|
||||
)
|
||||
from artemis.runtime.case_result import CaseTestResult, resolve_case_result
|
||||
from artemis.services.llm import final_review_budget
|
||||
from artemis.utils.logger import get_logger
|
||||
from artemis.utils.notes import save_verified_note
|
||||
|
||||
@@ -50,7 +51,6 @@ async def settle_flash_outcome(
|
||||
logger.warning(f"Flash 最终答复保存失败:{exc}")
|
||||
delivery = {"ok": False, "verified": False, "error": str(exc)}
|
||||
if final_check_enabled(ctx):
|
||||
timeout = float(getattr(ctx.execution_setup, "checkpoint_timeout", 180.0))
|
||||
publish_checker_event(
|
||||
ctx,
|
||||
{
|
||||
@@ -63,8 +63,8 @@ async def settle_flash_outcome(
|
||||
},
|
||||
)
|
||||
try:
|
||||
report = await asyncio.wait_for(
|
||||
run_final_check(
|
||||
report = await final_review_budget(ctx, attempt_id="final#1").run(
|
||||
lambda: run_final_check(
|
||||
ctx,
|
||||
goal=goal,
|
||||
plan_text="",
|
||||
@@ -74,7 +74,6 @@ async def settle_flash_outcome(
|
||||
execution_report=execution_report,
|
||||
report_delivery=delivery,
|
||||
),
|
||||
timeout=timeout,
|
||||
)
|
||||
result = report.test_result
|
||||
if report.report_corrections and directory:
|
||||
@@ -101,11 +100,7 @@ async def settle_flash_outcome(
|
||||
},
|
||||
)
|
||||
except Exception as exc:
|
||||
detail = (
|
||||
f"超过 {timeout:g} 秒"
|
||||
if isinstance(exc, TimeoutError)
|
||||
else f"{type(exc).__name__}: {exc}"
|
||||
)
|
||||
detail = final_review_error_text(exc)
|
||||
logger.warning(f"Flash 测试验收未完成:{detail}")
|
||||
result = CaseTestResult(
|
||||
status="inconclusive", reason=f"操作已结束,但测试验收未完成:{detail}。"
|
||||
|
||||
Reference in new issue
Block a user