Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Add Claude Haiku 5.5 as an LLM_NAME variant for v1 (SKY-18088) (#8868)
Cindy Li57890df3b43c
diff --git a/skyvern/forge/sdk/copilot/enforcement.py b/skyvern/forge/sdk/copilot/enforcement.pyindex 979981895..1b5a884fd 100644--- a/skyvern/forge/sdk/copilot/enforcement.py+++ b/skyvern/forge/sdk/copilot/enforcement.py@@ -643,6 +643,14 @@ def _bounded_error_codes(codes: Any) -> list[str]:return [str(c)[:64] for c in codes if isinstance(c, str)][:_PACKET_LIST_CAP]+def _bounded_scalars(fact: dict[str, Any]) -> dict[str, bool | int | float | str]:+ return {+ str(key)[:64]: item if isinstance(item, (bool, int, float)) else item[:_PACKET_NOTICE_CAP]+ for key, item in list(fact.items())[:_PACKET_LIST_CAP]+ if isinstance(item, (bool, int, float, str))+ }++def _retained_run_packet(packet: Any) -> dict[str, Any] | None:"""The packet's identity and failure scalars, bounded. Lists are tails, so they yield first."""if not isinstance(packet, dict):@@ -656,6 +664,12 @@ def _retained_run_packet(packet: Any) -> dict[str, Any] | None:run_id = run.get("workflow_run_id")status = run.get("status")bounded_run = {k: v for k, v in (("workflow_run_id", run_id), ("status", status)) if v}+ # A later test selection reads an older run by which browser ran it and how that browser+ # started; reduced to an id and a status, the run reads as having left its page for the next.+ for key in ("browser", "browser_start"):+ browser_fact = run.get(key)+ if isinstance(browser_fact, dict) and (scalars := _bounded_scalars(browser_fact)):+ bounded_run[key] = scalarsif bounded_run:kept["run"] = bounded_runchallenge = packet.get("challenge")diff --git a/skyvern/forge/sdk/copilot/tools/run_execution.py b/skyvern/forge/sdk/copilot/tools/run_execution.pyindex 81c577b4a..25db2cc95 100644--- a/skyvern/forge/sdk/copilot/tools/run_execution.py+++ b/skyvern/forge/sdk/copilot/tools/run_execution.py@@ -2317,6 +2317,8 @@ def _attach_run_session_facts(*,used_fresh_run_session: bool,run_detached_from_chat: bool,+ chat_browser_opened_for_run: bool,+ continued_earlier_test: bool,run_ok: bool,page_evidence: Mapping[str, Any] | None,) -> None:@@ -2327,13 +2329,26 @@ def _attach_run_session_facts(# A carried resume browser is also not the chat's, so detachment is the honest fact for# "can I look at this run's page from here", not whether the session was minted.data["run_detached_from_chat"] = run_detached_from_chat+ # Say which browser the run started in, so code that needed a signed-in state reads as started+ # somewhere else rather than as broken, and the next request can bring the blocks it needs.if used_fresh_run_session:- # Say that the page was blank, so code that needed a signed-in state reads as started- # somewhere else rather than as broken, and the next request can bring the blocks it needs.- data.setdefault(- "browser_start",- {"kind": "separate_blank_context", "restored_saved_profile": False, "inherited_browser_state": False},- )+ browser_start_kind = "separate_blank_context"+ elif run_detached_from_chat:+ browser_start_kind = "separate_context_continued_from_earlier_test"+ elif chat_browser_opened_for_run:+ browser_start_kind = "chat_browser_context_opened_for_this_run"+ elif continued_earlier_test:+ browser_start_kind = "chat_browser_context_continued_from_earlier_test"+ else:+ browser_start_kind = "chat_browser_context"+ data.setdefault(+ "browser_start",+ {+ "kind": browser_start_kind,+ "restored_saved_profile": False,+ "inherited_browser_state": not (used_fresh_run_session or chat_browser_opened_for_run),+ },+ )if not isinstance(page_evidence, Mapping):returndata["challenge_stalled_fresh_session"] = (@@ -3464,6 +3479,8 @@ async def _attach_post_run_browser_enrichment(run_ok: bool,used_fresh_run_session: bool,run_detached_from_chat: bool,+ chat_browser_opened_for_run: bool,+ continued_earlier_test: bool,origin_registry: OriginRunRedactionRegistry | None = None,) -> tuple[str, dict[str, Any] | None]:"""Probe the browser for post-run facts and stamp them onto an already-recorded run result.@@ -3586,6 +3603,8 @@ async def _attach_post_run_browser_enrichment(result_data,used_fresh_run_session=used_fresh_run_session,run_detached_from_chat=run_detached_from_chat,+ chat_browser_opened_for_run=chat_browser_opened_for_run,+ continued_earlier_test=continued_earlier_test,run_ok=run_ok,page_evidence=post_run_page_evidence,)@@ -3646,6 +3665,7 @@ async def _run_blocks_and_collect_debug(use_ephemeral_inputs: bool = True,new_exit: bool = False,verified_new_exit: FreshExitReceipt | None = None,+ chat_browser_opened_before_retry: bool = False,) -> dict[str, Any]:"""With ``new_exit``, run in a browser whose network exit is verified to differ from the most recent buildtest's; the model cannot choose or verify an exit, so the platform supplies it or says why it cannot."""@@ -4081,6 +4101,8 @@ async def _run_blocks_and_collect_debug(# Whether the run executed outside the chat's browser at all, by either route. This is what# gates the post-run rebind and the pane association, neither of which cares which route.run_detached_from_chat = False+ # The chat held no usable browser, so acquiring one opened it blank for this run.+ chat_browser_opened_for_run = Falsedebug_session_id: str | None = Nonerun_session_id: str | Nonenew_exit_receipt: FreshExitReceipt | None = None@@ -4164,10 +4186,14 @@ async def _run_blocks_and_collect_debug(else:# This id is dispatched into a workflow run without ever being attached here, so an# unverified session cannot be discovered later and must fail now instead.+ chat_session_id_before_acquisition = ctx.browser_session_idsession_err = await acquire_build_test_browser_session(ctx, fresh=False)if session_err is not None:return _with_build_test_acquisition_context(session_err, requested_block_labels=block_labels)run_session_id = ctx.browser_session_id+ chat_browser_opened_for_run = (+ chat_browser_opened_before_retry or run_session_id != chat_session_id_before_acquisition+ )dispatch_draft_workflow_id: str | None = None# run_task is the in-process inline execution task, only ever set on the dev-only inline path.@@ -4321,6 +4347,7 @@ async def _run_blocks_and_collect_debug(use_ephemeral_inputs=use_ephemeral_inputs,new_exit=new_exit,verified_new_exit=new_exit_receipt,+ chat_browser_opened_before_retry=chat_browser_opened_for_run,)execution.dispatched_input_values = copy.deepcopy(data)@@ -4792,6 +4819,8 @@ async def _run_blocks_and_collect_debug(result["data"],used_fresh_run_session=used_fresh_run_session,run_detached_from_chat=run_detached_from_chat,+ chat_browser_opened_for_run=chat_browser_opened_for_run,+ continued_earlier_test=resume_session_id is not None,run_ok=False,page_evidence=_same_run_page_evidence_for_result(ctx, workflow_run.workflow_run_id),)@@ -5063,6 +5092,8 @@ async def _run_blocks_and_collect_debug(run_ok=run_ok,used_fresh_run_session=used_fresh_run_session,run_detached_from_chat=run_detached_from_chat,+ chat_browser_opened_for_run=chat_browser_opened_for_run,+ continued_earlier_test=resume_session_id is not None,origin_registry=origin_registry,)settle_terminal_challenge_after_enrichment(ctx, response)diff --git a/skyvern/forge/sdk/workflow/code_block_safety.py b/skyvern/forge/sdk/workflow/code_block_safety.pyindex 97acdb5ae..152c0fe19 100644--- a/skyvern/forge/sdk/workflow/code_block_safety.py+++ b/skyvern/forge/sdk/workflow/code_block_safety.py@@ -213,6 +213,14 @@ SANDBOX_ONLY_BUILTINS: frozenset[str] = frozenset()+def json_safe_default(item: object) -> str:+ # isinstance falls back to reading item.__class__, which runs a block-defined __getattribute__.+ # A datetime is a date subclass and keeps the placeholder rather than losing its time.+ if issubclass(type(item), datetime.date) and not issubclass(type(item), datetime.datetime):+ return datetime.date.isoformat(item) # type: ignore[arg-type]+ return f"Object '{type(item)}' is not JSON serializable"++def safe_builtins() -> dict[str, Any]:"""Builtins a CodeBlock may use while sharing the worker process; dunders drop out via the underscore filter."""denied = ALWAYS_DENIED_BUILTINS | SANDBOX_ONLY_BUILTINSdiff --git a/skyvern/forge/sdk/workflow/models/block.py b/skyvern/forge/sdk/workflow/models/block.pyindex ed39076ef..d310bf8cc 100644--- a/skyvern/forge/sdk/workflow/models/block.py+++ b/skyvern/forge/sdk/workflow/models/block.py@@ -218,7 +218,7 @@ from skyvern.forge.sdk.workflow.code_block_authorized_files import ()from skyvern.forge.sdk.workflow.code_block_safety import BLOCKED_ATTRS as CODE_BLOCK_BLOCKED_ATTRSfrom skyvern.forge.sdk.workflow.code_block_safety import is_safe_code as _shared_is_safe_code-from skyvern.forge.sdk.workflow.code_block_safety import module_shims, safe_builtins+from skyvern.forge.sdk.workflow.code_block_safety import json_safe_default, module_shims, safe_builtinsfrom skyvern.forge.sdk.workflow.constants import OUTPUT_PARAMETER_MAX_VALUE_BYTESfrom skyvern.forge.sdk.workflow.context_manager import (NON_SECRET_CREDENTIAL_FIELDS,@@ -10374,9 +10374,7 @@ async def wrapper({default_args}):# would either crash registration or, via the default= fallback, replace the value with a# useless placeholder — normalize the wrapper family to its selector/marker first.result = json_safe_recorder_output(result)- result = json.loads(- json.dumps(result, default=lambda value: f"Object '{type(value)}' is not JSON serializable")- )+ result = json.loads(json.dumps(result, default=json_safe_default))# Mask resolved secrets (OTP codes, passwords) a user assigned to a local before they# reach captured locals, the persisted output, or the logged value. Mirrors# HttpRequestBlock and is stronger than the name-based excluded_parameter_keys filter.diff --git a/tests/unit/test_copilot_diagnosis_repair_contract.py b/tests/unit/test_copilot_diagnosis_repair_contract.pyindex 1104ded2e..ddf47904a 100644--- a/tests/unit/test_copilot_diagnosis_repair_contract.py+++ b/tests/unit/test_copilot_diagnosis_repair_contract.py@@ -3629,6 +3629,8 @@ def test_fresh_session_run_envelope_carries_typed_session_facts() -> None:data,used_fresh_run_session=True,run_detached_from_chat=False,+ chat_browser_opened_for_run=False,+ continued_earlier_test=False,run_ok=False,page_evidence=_challenge_wall_page_evidence(ChallengeKind.CAPTCHA.value),)@@ -3644,6 +3646,8 @@ def test_run_envelope_omits_the_challenge_stall_fact_without_a_structured_packetdata,used_fresh_run_session=True,run_detached_from_chat=False,+ chat_browser_opened_for_run=False,+ continued_earlier_test=False,run_ok=False,page_evidence=None,)@@ -3659,6 +3663,8 @@ def test_passing_fresh_session_run_did_not_stall_on_the_challenge() -> None:data,used_fresh_run_session=True,run_detached_from_chat=False,+ chat_browser_opened_for_run=False,+ continued_earlier_test=False,run_ok=True,page_evidence=_challenge_wall_page_evidence(ChallengeKind.CAPTCHA.value),)diff --git a/tests/unit/test_copilot_generated_browser_page_state_repair.py b/tests/unit/test_copilot_generated_browser_page_state_repair.pyindex 76aed4168..ea0fa4978 100644--- a/tests/unit/test_copilot_generated_browser_page_state_repair.py+++ b/tests/unit/test_copilot_generated_browser_page_state_repair.py@@ -26,11 +26,13 @@ from skyvern.forge.sdk.copilot.build_test_outcome import (from skyvern.forge.sdk.copilot.composition_evidence import model_visible_composition_evidence, parse_composition_htmlfrom skyvern.forge.sdk.copilot.config import BlockAuthoringPolicyfrom skyvern.forge.sdk.copilot.context import CodeAuthoringRepairContext, CopilotContext+from skyvern.forge.sdk.copilot.enforcement import _summarize_tool_outputfrom skyvern.forge.sdk.copilot.output_contracts import code_block_available_contracts_by_labelfrom skyvern.forge.sdk.copilot.output_utils import (_compact_packet_for_aggregate_limit,project_build_test_packet_for_llm,project_direct_test_handoff_packet_for_llm,+ sanitize_tool_result_for_llm,)from skyvern.forge.sdk.copilot.runtime_authoring_repair import (REPAIR_INSTRUCTION_MAX_CHARS,@@ -43,6 +45,7 @@ from skyvern.forge.sdk.copilot.runtime_authoring_repair import ()from skyvern.forge.sdk.copilot.tools.run_execution import (CopilotExecutionSnapshot,+ _attach_run_session_facts,_build_recorded_build_test_outcome,_ExecutionResult,_failure_action_trace_summary,@@ -50,6 +53,7 @@ from skyvern.forge.sdk.copilot.tools.run_execution import (_record_run_blocks_result,_RunExecution,build_test_evidence_packet,+ finalize_build_test_result,)from skyvern.forge.sdk.workflow.models.code_block_recorder import CODE_BLOCK_FILENAME, user_code_line_from_exceptionfrom skyvern.forge.sdk.workflow.models.workflow import Workflow@@ -1045,3 +1049,74 @@ def test_hidden_control_crowded_page_keeps_text_labeled_summaries_first() -> Nonassert summaries[0] == "Export CSV"for _, selector in _HIDDEN_CONTROL_EXPANDERS.values():assert any(summary.startswith(selector) for summary in summaries[1:]), summaries+++_SIGNED_OUT_READ_LABEL = "read_visitors"+_SIGNED_OUT_WRITE_LABEL = "write_report_cell"+_SIGNED_OUT_TITLE = "Sign in"+++def _signed_out_focused_result() -> dict[str, Any]:+ """A read and a native write that completed on the sign-in page, in the chat's browser."""+ data: dict[str, Any] = {+ "workflow_run_id": "wr_signed_out_focused",+ "browser_session_id": "pbs_chat",+ "overall_status": "completed",+ "requested_block_labels": [_SIGNED_OUT_READ_LABEL, _SIGNED_OUT_WRITE_LABEL],+ "executed_block_labels": [_SIGNED_OUT_READ_LABEL, _SIGNED_OUT_WRITE_LABEL],+ "current_url": "https://metrics.fixture.test/dashboard",+ "page_title": _SIGNED_OUT_TITLE,+ "blocks": [+ {+ "workflow_run_block_id": "wrb_read_visitors",+ "label": _SIGNED_OUT_READ_LABEL,+ "block_type": "EXTRACTION",+ "status": "completed",+ "output": {"status": "completed", "extracted_information": {"visitors": None}},+ },+ {+ "workflow_run_block_id": "wrb_write_report_cell",+ "label": _SIGNED_OUT_WRITE_LABEL,+ "block_type": "HTTP_REQUEST",+ "status": "completed",+ "output": {"status_code": 200, "request_body": {"cell": "A1", "value": "None"}},+ },+ ],+ }+ _attach_run_session_facts(+ data,+ used_fresh_run_session=False,+ run_detached_from_chat=False,+ chat_browser_opened_for_run=False,+ continued_earlier_test=False,+ run_ok=True,+ page_evidence=None,+ )+ return {"ok": True, "data": data}+++def test_a_signed_out_focused_run_reaches_the_model_as_facts_and_keeps_its_browser_as_an_older_result() -> None:+ ctx = _copilot_context()+ result = _signed_out_focused_result()+ _record_run_blocks_result(ctx, copy.deepcopy(result))++ model_facing = sanitize_tool_result_for_llm(+ "run_blocks_and_collect_debug",+ finalize_build_test_result(ctx, source_tool="run_blocks_and_collect_debug", result=result),+ )++ assert model_facing["ok"] is True and "error" not in model_facing+ packet = model_facing["data"]["build_test_packet"]+ assert packet["page_state"]["title"] == _SIGNED_OUT_TITLE+ outputs = {entry["label"]: entry["output"] for entry in packet["registered_outputs"]}+ assert outputs[_SIGNED_OUT_READ_LABEL]["extracted_information"] == {"visitors": None}+ assert outputs[_SIGNED_OUT_WRITE_LABEL]["request_body"] == {"cell": "A1", "value": "None"}+ assert packet["run"]["browser_start"]["kind"] == "chat_browser_context"+ outcome = ctx.latest_recorded_build_test_outcome+ assert outcome is not None and outcome.verdict == "not_authoritative"++ older = _summarize_tool_output(json.dumps(model_facing))+ kept = json.loads(older)["build_test_packet"]["run"]+ for key in ("workflow_run_id", "status", "browser", "browser_start"):+ assert kept[key] == packet["run"][key], key+ assert _summarize_tool_output(older) == olderdiff --git a/tests/unit/test_copilot_watchdog.py b/tests/unit/test_copilot_watchdog.pyindex a6096a8f8..3b4461f71 100644--- a/tests/unit/test_copilot_watchdog.py+++ b/tests/unit/test_copilot_watchdog.py@@ -21,6 +21,8 @@ from skyvern.forge.sdk.copilot.context import CopilotContextfrom skyvern.forge.sdk.copilot.repair_origin_run import (OriginBlockOutput,OriginExecutionSettings,+ OriginOutputRefusal,+ OriginOutputRefusalDetail,OriginOutputSnapshot,SelectedOutputSource,)@@ -602,6 +604,7 @@ async def test_non_paused_watchdog_exit_still_cancels_and_clears(monkeypatch: pyresult = await _run_blocks_and_collect_debug({"block_labels": ["extract_heading"], "parameters": {}}, ctx)assert result["data"]["control_signal"]["kind"] == "watchdog_ceiling"+ assert result["data"]["browser_start"]["kind"] == "separate_context_continued_from_earlier_test"harness["cancel_run_task"].assert_awaited_once()harness["clear"].assert_awaited_once()assert _adopted_detached_tasks(before) == []@@ -617,6 +620,96 @@ async def test_non_paused_watchdog_exit_still_cancels_and_clears(monkeypatch: pyassert "Run ID:" in result["error"]+ ("chat_session_id", "resume_session_id", "acquired_session_id", "kind", "inherited_browser_state"),+ [+ ("pbs_chat", None, "pbs_chat", "chat_browser_context", True),+ ("pbs_chat", "pbs_chat", "pbs_chat", "chat_browser_context_continued_from_earlier_test", True),+ (None, None, "pbs_chat", "chat_browser_context_opened_for_this_run", False),+ ("pbs_chat", "pbs_chat", "pbs_chat_replacement", "chat_browser_context_opened_for_this_run", False),+ ],+)+async def test_a_chat_browser_run_at_the_ceiling_says_which_browser_it_started_in(+ monkeypatch: pytest.MonkeyPatch,+ chat_session_id: str | None,+ resume_session_id: str | None,+ acquired_session_id: str,+ kind: str,+ inherited_browser_state: bool,+) -> None:+ harness = await _install_run_harness(+ monkeypatch, workflow_yaml=SEARCH_THEN_SELECT_WORKFLOW_YAML, polled_status="running"+ )+ _install_advancing_clock(monkeypatch)++ async def _acquire(ctx: CopilotContext, **_kwargs: object) -> None:+ ctx.browser_session_id = acquired_session_id++ monkeypatch.setattr(run_execution, "acquire_build_test_browser_session", _acquire)+ ctx = make_copilot_ctx(browser_session_id=chat_session_id)+ ctx.staged_workflow = harness["workflow"]+ ctx.frontier_resume_session_id = resume_session_id++ result = await _run_blocks_and_collect_debug({"block_labels": ["select_first_result"], "parameters": {}}, ctx)++ assert result["data"]["control_signal"]["kind"] == "watchdog_ceiling"+ assert result["data"]["browser_start"] == {+ "kind": kind,+ "restored_saved_profile": False,+ "inherited_browser_state": inherited_browser_state,+ }+++async def test_a_retry_after_a_refused_earlier_output_keeps_the_chat_browser_it_opened_as_blank(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ harness = await _install_run_harness(+ monkeypatch, workflow_yaml=SEARCH_THEN_SELECT_WORKFLOW_YAML, polled_status="running"+ )+ _install_advancing_clock(monkeypatch)++ async def _acquire(ctx: CopilotContext, **_kwargs: object) -> None:+ ctx.browser_session_id = ctx.browser_session_id or "pbs_chat"++ refusals = [+ OriginOutputRefusalDetail(+ reason=OriginOutputRefusal.CHANGED_PRODUCER, block_label="run_search", origin_workflow_run_id="wr_origin"+ )+ ]++ def _refuse_once_after_persistence(*_args: object, check_settings: bool = True, **_kwargs: object) -> object:+ return refusals.pop() if check_settings and refusals else None++ monkeypatch.setattr(run_execution, "acquire_build_test_browser_session", _acquire)+ monkeypatch.setattr(run_execution, "selected_output_run_refusal", _refuse_once_after_persistence)+ ctx = make_copilot_ctx(browser_session_id=None)+ ctx.staged_workflow = harness["workflow"]+ origin = OriginOutputSnapshot(+ definition=harness["workflow"].workflow_definition,+ outputs={+ "run_search": OriginBlockOutput(+ status=BlockStatus.completed, has_value=True, created_at=datetime.now(UTC), value={"results": []}+ )+ },+ settings=OriginExecutionSettings.of(harness["workflow"]),+ )+ ctx.repair_origin_outputs = origin+ ctx.frontier_selected_output_sources = {+ "run_search": SelectedOutputSource("run_search", "wr_origin", "origin", origin)+ }++ result = await _run_blocks_and_collect_debug({"block_labels": ["select_first_result"], "parameters": {}}, ctx)++ assert refusals == []+ assert result["data"]["browser_start"] == {+ "kind": "chat_browser_context_opened_for_this_run",+ "restored_saved_profile": False,+ "inherited_browser_state": False,+ }++@pytest.mark.asyncioasync def test_non_success_watchdog_result_types_selected_failed_block_locators(monkeypatch: pytest.MonkeyPatch,diff --git a/tests/unit/test_workflow_service_cancel.py b/tests/unit/test_workflow_service_cancel.pyindex 256f7d273..da425b17c 100644--- a/tests/unit/test_workflow_service_cancel.py+++ b/tests/unit/test_workflow_service_cancel.py@@ -57,6 +57,16 @@ async def test_mark_canceled_if_not_final_returns_conditional_result()+def _patch_service_log(monkeypatch: pytest.MonkeyPatch, **methods: object) -> None:+ """Replace the service module's LOG rather than a method on it. Undoing a patched method on+ structlog's lazy proxy leaves a bound logger stuck to the proxy, and later tests in the same+ process then miss that module's lines in structlog.testing.capture_logs."""+ log = MagicMock(wraps=service_module.LOG)+ for name, method in methods.items():+ setattr(log, name, method)+ monkeypatch.setattr(service_module, "LOG", log)++def _make_updated_row(now: datetime | None = None) -> MagicMock:now = now or datetime.now(UTC)row = MagicMock()@@ -202,7 +212,7 @@ async def test_mark_canceled_if_not_final_logs_duration_metrics(def fake_info(event: str, **kwargs: object) -> None:info_calls.append((event, dict(kwargs)))- monkeypatch.setattr(service_module.LOG, "info", fake_info)+ _patch_service_log(monkeypatch, info=fake_info)svc = WorkflowService()result = await svc.mark_workflow_run_as_canceled_if_not_final(workflow_run_id="wr_live")@@ -276,7 +286,7 @@ async def test_mark_canceled_if_not_final_skips_side_effects_on_terminal_row(def fake_info(event: str, **kwargs: object) -> None:info_calls.append(event)- monkeypatch.setattr(service_module.LOG, "info", fake_info)+ _patch_service_log(monkeypatch, info=fake_info)svc = WorkflowService()result = await svc.mark_workflow_run_as_canceled_if_not_final(workflow_run_id="wr_already_done")@@ -537,7 +547,7 @@ async def test_cancel_policy_run_retries_failed_terminal_release_without_raisingmonkeypatch.setattr(svc, "run_terminal_side_effects", fail_release)warning = MagicMock()- monkeypatch.setattr(service_module.LOG, "warning", warning)+ _patch_service_log(monkeypatch, warning=warning)# The cancel operation itself succeeded; a failed best-effort release is retried and left# for the durable recovery owner instead of being raised through the API path.