fix: give final acceptance a shared retry budget and diagnostics

This commit is contained in:
chenmingxuan committed 2026-10-18 20:51:19 +08:00
1 parent 50638d4130
commit 32441e79c4
18 files changed
+779 -40

No files matched your search

+6 -10
View File
@@ -62,6 +62,8 @@ from artemis.graph.checkpoints import (
from artemis.graph.perception import perception_node
from artemis.graph.state import State
from artemis.graph.visibility import strict_state
from artemis.llm.diagnostics import final_review_error_text
from artemis.services.llm import final_review_budget
from artemis.tools.command_tool import (
HANG_GUIDANCE,
manage_task_wrapper,
@@ -325,7 +327,6 @@ async def _exit_settlement_node(state: State, ctx: ArtemisContext):
attempt_no = ctx.final_check_attempts + 1
ctx.final_check_attempts = attempt_no
final_attempt_id = f"final#{attempt_no}"
checkpoint_timeout = float(getattr(setup, "checkpoint_timeout", 180.0) or 180.0)
ledger = read_ledger(base_dir)
def _final_event(status: str, verdicts: list[dict], **extra) -> None:
@@ -345,8 +346,8 @@ async def _exit_settlement_node(state: State, ctx: ArtemisContext):
)
try:
review = asyncio.wait_for(
run_final_check(
review = final_review_budget(ctx, attempt_id=final_attempt_id).run(
lambda: run_final_check(
ctx,
goal=getattr(state, "initial_goal", ""),
plan_text=plan_text,
@@ -356,7 +357,6 @@ async def _exit_settlement_node(state: State, ctx: ArtemisContext):
execution_report=execution_report,
report_delivery=report_delivery,
),
timeout=checkpoint_timeout,
)
control = getattr(ctx, "task_control", None)
if getattr(ctx, "exploration_id", None) and control:
@@ -379,11 +379,7 @@ async def _exit_settlement_node(state: State, ctx: ArtemisContext):
logger.warning(f"Final check errored ({e}); releasing fail-open.")
from artemis.runtime.case_result import CaseTestResult
detail = (
f"超过 {checkpoint_timeout:g} 秒"
if isinstance(e, TimeoutError)
else f"{type(e).__name__}: {e}"
)
detail = final_review_error_text(e)
case_result = CaseTestResult(
status="inconclusive", reason=f"最终验收未完成:{detail}。"
)
@@ -413,7 +409,7 @@ async def _exit_settlement_node(state: State, ctx: ArtemisContext):
"suggestion": "",
}
)
_final_event("error", error_verdicts, error=str(e), route="end")
_final_event("error", error_verdicts, error=detail, route="end")
report = None
if report is not None: