mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-25 19:22:33 +00:00
恢复被驳回的运行:照 end_reason 说「被驳回」,和继续运行同一个错误码 run_rejected
验收:对被驳回的运行调 POST /api/runs/{id}/resume,回的是「这次运行已取消,没有待处理的审批,无法恢复。已取消的
运行请重新发起」,/continue 却是对的(run_rejected)。resume 只看 status,cancelled 一律说「已取消」;存量的
failed + 驳回还会被说成「失败的运行可点继续运行」,而继续运行其实会被拒。
改法:runner 加 _resume_refused:cancelled + end_reason=rejected、以及加 end_reason 之前记成 failed 的驳回
(_rejected_before,同 continue_failed 的判断)抛 ContinueRefused(REJECTED_RESUME, code=RUN_REJECTED),别的照
_cannot_resume。resume 开头的状态检查、等审批凑齐时发现运行已经不在 interrupted 两处都用它。/resume 接口像
/continue 一样把带机器码的拒绝回成 CodedHTTPException(409, …, code)。ContinueRefused 是 ValueError 的子类,
别的调用方(待办服务)照旧按 ValueError 接。
测试:test_run_rejected 新增一条:驳回的运行 /resume 回 409 + run_rejected、说「被驳回」;手动停止的照旧说
已取消、不带这个码;存量 failed + 驳回也回 run_rejected,不再叫人点「继续运行」。去掉修复回跑挂。
This commit is contained in:
@@ -418,6 +418,8 @@ async def resume_run(
|
||||
approval = await session.get(Approval, target)
|
||||
if approval is not None and approval.run_id == run_id and approval.status == "pending":
|
||||
return await _respond_to(target, payload.response, x_actor)
|
||||
from app.engine.runner import ContinueRefused
|
||||
|
||||
try:
|
||||
# approval_id 以前定义了却从没传下去——一次运行里有多条待审批时,
|
||||
# 引擎无从知道这次回复的是哪一条
|
||||
@@ -428,6 +430,9 @@ async def resume_run(
|
||||
)
|
||||
except KeyError as e:
|
||||
raise _missing(e) from e
|
||||
except ContinueRefused as e:
|
||||
# 被驳回的(run_rejected):和 /continue 同一个机器码
|
||||
raise CodedHTTPException(409, str(e), e.code) from e
|
||||
except ValueError as e:
|
||||
raise HTTPException(409, str(e)) from e
|
||||
|
||||
|
||||
Reference in New Issue
Block a user