Jev 운영 배포 검증과 남은 확인 항목 기록

This commit is contained in:
Yun Chan 2026-09-22 21:49:10 +09:00
parent 969d9e2c3c
commit 20dc30c8aa
7 changed files with 291 additions and 15 deletions

View file

@ -280,6 +280,57 @@ async def _run_turn(
return record, context.state_after, generated_text if done_payload is not None and error_code is None else None
def _is_stateless_openai_phase(runtime: dict[str, Any], phase: dict[str, Any]) -> bool:
completed_turns = [turn for turn in phase["turns"] if turn["status"] == "done"]
settings = runtime["settings"]
return (
bool(completed_turns)
and all(turn["generation"]["provider"] == "openai" for turn in completed_turns)
and (settings.live_client_provider == "openai" or settings.engine_mode == "openai")
)
def _mark_cleanup_failed(phase: dict[str, Any]) -> None:
phase["session_closed"] = False
phase["cleanup_status"] = "failed"
phase["cleanup_error"] = "engine_close_failed"
if phase["status"] == "done":
phase["status"] = "error"
phase["error"] = "engine_close_failed"
async def _cleanup_synthetic_session(
*,
runtime: dict[str, Any],
phase: dict[str, Any],
session_id: str,
) -> None:
try:
response = await runtime["engine_client"].client.delete(f"/session/{session_id}")
phase["cleanup_http_status"] = response.status_code
response.raise_for_status()
payload = response.json()
except asyncio.CancelledError:
raise
except Exception:
_mark_cleanup_failed(phase)
return
if not isinstance(payload, dict) or set(payload) != {"closed"} or type(payload["closed"]) is not bool:
_mark_cleanup_failed(phase)
return
phase["cleanup_closed"] = payload["closed"]
if payload["closed"]:
phase["session_closed"] = True
phase["cleanup_status"] = "closed"
elif _is_stateless_openai_phase(runtime, phase):
phase["session_closed"] = False
phase["cleanup_status"] = "not_required"
else:
_mark_cleanup_failed(phase)
async def _run_phase(
*,
runtime: dict[str, Any],
@ -337,13 +388,7 @@ async def _run_phase(
return phase
finally:
settings.client_affect_provider = original_provider
closed = await runtime["engine_client"].close_session(session_id)
phase["session_closed"] = closed
if not closed:
phase["cleanup_error"] = "engine_close_failed"
if phase["status"] == "done":
phase["status"] = "error"
phase["error"] = "engine_close_failed"
await _cleanup_synthetic_session(runtime=runtime, phase=phase, session_id=session_id)
def _source_sha256() -> dict[str, str]: