Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-12998): route verified copilot fixes through the review gate (#7739)
Celal Zamanoğluf8c2cf778a8a
diff --git a/skyvern-frontend/src/api/types.ts b/skyvern-frontend/src/api/types.tsindex 1e8aa1364..8319b7d63 100644--- a/skyvern-frontend/src/api/types.ts+++ b/skyvern-frontend/src/api/types.ts@@ -830,6 +830,8 @@ export type WorkflowRunStatusApiResponse = {status: Status;proxy_location: ProxyLocation | null;webhook_callback_url: string | null;+ totp_verification_url: string | null;+ totp_identifier: string | null;extra_http_headers: Record<string, string> | null;created_at: string;queued_at: string | null;@@ -871,6 +873,8 @@ export type WorkflowRunStatusApiResponseWithWorkflow = {status: Status;proxy_location: ProxyLocation | null;webhook_callback_url: string | null;+ totp_verification_url: string | null;+ totp_identifier: string | null;extra_http_headers: Record<string, string> | null;created_at: string;queued_at: string | null;diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.reviewGate.test.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.reviewGate.test.tsxindex 3123edc49..19418d4c7 100644--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.reviewGate.test.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.reviewGate.test.tsx@@ -391,7 +391,7 @@ describe("WorkflowCopilotChat — g2 review gate (flag-on, SKY-12136)", () => {expect(screen.queryByText("1 proposal pending · Review")).toBeNull();});- it("clears a stale bypassed gate when a later turn auto-applies (stale Accept can't reapply over the newer canvas)", async () => {+ it("clears a stale pending gate when a later turn is auto-applied (stale Accept can't reapply over the newer canvas)", async () => {flagMap.current = { [COPILOT_UX_V1_FLAG]: true };await renderChat();@@ -403,7 +403,7 @@ describe("WorkflowCopilotChat — g2 review gate (flag-on, SKY-12136)", () => {});expect(screen.getByRole("button", { name: "Accept" })).toBeTruthy();- // Bypass: this follow-up comes back auto-applied instead of another gate.+ // Always-accept echo: this follow-up comes back auto-applied instead of another gate.await submit("actually just fix the typo directly");await waitFor(() => expect(postStreaming).toHaveBeenCalledTimes(2));expect(streamCalls[1]!.body.keep_pending_proposal).toBe(true);diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.test.ts b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.test.tsindex 49bf92199..9cabe18b4 100644--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.test.ts+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.test.ts@@ -30,6 +30,19 @@ describe("shouldAutoApplyWorkflowResponse", () => {).toBe(true);});+ it("keeps a verified fix pending when auto accept is off and the backend did not apply it", () => {+ // A verified fix the backend left pending (workflow_applied=false) must NOT+ // auto-apply when auto accept is off — it lands as a pending proposal for+ // the review gate.+ expect(+ shouldAutoApplyWorkflowResponse(+ response({ workflow_applied: false }),+ false,+ false,+ ),+ ).toBe(false);+ });+it.each(["review_untested", "review_tested"] as const)("forces explicit review for %s proposals",(proposal_disposition) => {diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunInputsSection.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunInputsSection.test.tsxindex a99e858b1..b38b78355 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunInputsSection.test.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunInputsSection.test.tsx@@ -187,6 +187,31 @@ describe("RunInputsSection", () => {);});+ test("renders Other inputs meta rows as copyable label/value pairs, including TOTP", () => {+ render(+ <RunInputsSection+ {...emptyProps}+ meta={[+ { label: "TOTP URL", value: "https://example.test/totp" },+ { label: "TOTP identifier", value: "totp-identifier-1" },+ ]}+ />,+ );++ expect(screen.queryByText("Other inputs")).not.toBeNull();+ // Run inputs / Block prompts sections stay absent when only meta is present.+ expect(screen.queryByText("Run inputs")).toBeNull();+ expect(screen.queryByText("Block prompts")).toBeNull();+ expect(screen.queryByText("TOTP URL")).not.toBeNull();+ expect(screen.queryByText("https://example.test/totp")).not.toBeNull();+ expect(screen.queryByText("TOTP identifier")).not.toBeNull();+ expect(screen.queryByText("totp-identifier-1")).not.toBeNull();+ // Every meta row exposes a copy button wired to its value.+ expect(+ screen.getAllByRole("button", { name: "Copy to clipboard" }),+ ).toHaveLength(2);+ });+test("renders the whole prompt as one wrapped block, not per-line rows", () => {// Prose keeps the entire prompt in the DOM and clamps height via CSS; the// old code inset sliced hidden lines out, so a collapsed multi-line promptdiff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsxindex 2ce8d8765..c17933a14 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx@@ -330,9 +330,11 @@ describe("RunView view toggles", () => {expect(scope.queryByText("Credits")).toBeNull();});- test("Inputs view shows the run's input metadata", () => {+ test("Inputs view shows the run's input metadata, including TOTP diagnostics", () => {seedCompletedRun({webhook_callback_url: "https://example.test/hook",+ totp_verification_url: "https://example.test/totp",+ totp_identifier: "totp-identifier-1",});const { container } = renderRunView();const scope = within(container);@@ -340,6 +342,42 @@ describe("RunView view toggles", () => {fireEvent.click(scope.getByRole("button", { name: "Inputs" }));expect(scope.getByText("Webhook URL")).not.toBeNull();expect(scope.getByText("https://example.test/hook")).not.toBeNull();+ expect(scope.getByText("TOTP URL")).not.toBeNull();+ expect(scope.getByText("https://example.test/totp")).not.toBeNull();+ expect(scope.getByText("TOTP identifier")).not.toBeNull();+ expect(scope.getByText("totp-identifier-1")).not.toBeNull();+ });++ test("Inputs view sources TOTP from task_v2 when the top-level run omits it", () => {+ seedCompletedRun({+ totp_verification_url: null,+ totp_identifier: null,+ task_v2: {+ totp_verification_url: "https://example.test/totp-v2",+ totp_identifier: "totp-identifier-v2",+ },+ });+ const { container } = renderRunView();+ const scope = within(container);++ fireEvent.click(scope.getByRole("button", { name: "Inputs" }));+ expect(scope.getByText("TOTP URL")).not.toBeNull();+ expect(scope.getByText("https://example.test/totp-v2")).not.toBeNull();+ expect(scope.getByText("TOTP identifier")).not.toBeNull();+ expect(scope.getByText("totp-identifier-v2")).not.toBeNull();+ });++ test("Inputs view omits TOTP rows when the run carries no TOTP config", () => {+ seedCompletedRun({+ webhook_callback_url: "https://example.test/hook",+ });+ const { container } = renderRunView();+ const scope = within(container);++ fireEvent.click(scope.getByRole("button", { name: "Inputs" }));+ expect(scope.getByText("Webhook URL")).not.toBeNull();+ expect(scope.queryByText("TOTP URL")).toBeNull();+ expect(scope.queryByText("TOTP identifier")).toBeNull();});test("Code view renders the shared WorkflowRunCode surface", () => {diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsxindex 6b7b62827..ee11f829d 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx@@ -339,6 +339,16 @@ export function RunView({});};pushMeta("Webhook URL", workflowRun?.webhook_callback_url);+ // Task 2.0 runs store TOTP config on task_v2, not the top-level run.+ pushMeta(+ "TOTP URL",+ workflowRun?.totp_verification_url ??+ workflowRun?.task_v2?.totp_verification_url,+ );+ pushMeta(+ "TOTP identifier",+ workflowRun?.totp_identifier ?? workflowRun?.task_v2?.totp_identifier,+ );pushMeta("Proxy", workflowRun?.proxy_location);pushMeta("Extra HTTP headers", workflowRun?.extra_http_headers);pushMeta("Browser session", workflowRun?.browser_session_id);diff --git a/skyvern/forge/sdk/copilot/agent.py b/skyvern/forge/sdk/copilot/agent.pyindex 33ce54ec4..5ab8c44ca 100644--- a/skyvern/forge/sdk/copilot/agent.py+++ b/skyvern/forge/sdk/copilot/agent.py@@ -1962,8 +1962,6 @@ def _make_agent_result(result = AgentResult(global_llm_context=final_context, turn_outcome=turn_outcome, **kwargs)if ctx is not None and result.turn_outcome is not None:result.turn_outcome = with_copilot_code_mode_diagnostics(result.turn_outcome, ctx)- if ctx is not None and not result.apply_without_review:- result.apply_without_review = _should_apply_code_only_success_without_review(ctx, result.proposal_disposition)if ctx is not None and result.completion_criteria_turn_state is None:result.completion_criteria_turn_state = getattr(ctx, "completion_criteria_turn_state", None)if ctx is not None and result.code_artifact_metadata is None:@@ -1978,19 +1976,6 @@ def _make_agent_result(return result-def _should_apply_code_only_success_without_review(ctx: CopilotContext, disposition: object) -> bool:- return (- disposition == "auto_applicable"- and verified_goal_claim_authorized(ctx)- and ctx.block_authoring_policy == BlockAuthoringPolicy.CODE_ONLY_BROWSER- and ctx.last_test_ok is True- and ctx.last_full_workflow_test_ok is True- and not ctx.last_test_suspicious_success- and ctx.has_staged_proposal- and ctx.staged_workflow is not None- )--def _build_outcome_adjudication_payload(ctx: CopilotContext) -> NarrativeOutcomeAdjudication | None:turn_state = getattr(ctx, "completion_criteria_turn_state", None)if turn_state is None:diff --git a/skyvern/forge/sdk/copilot/context.py b/skyvern/forge/sdk/copilot/context.pyindex a16bad773..f39907caa 100644--- a/skyvern/forge/sdk/copilot/context.py+++ b/skyvern/forge/sdk/copilot/context.py@@ -684,9 +684,6 @@ class AgentResult:cancelled: bool = False# Controls whether the route may auto-apply the proposal or must force explicit review.proposal_disposition: ProposalDisposition = "auto_applicable"- # Successful code-only build turns can be applied without requiring the- # chat's sticky "Always accept" setting.- apply_without_review: bool = Falseoutput_policy_diagnostics: dict[str, Any] | None = Noneturn_outcome: TurnOutcome | None = Noneturn_id: str | None = Nonediff --git a/skyvern/forge/sdk/copilot/terminal_envelope.py b/skyvern/forge/sdk/copilot/terminal_envelope.pyindex d73830e87..bb7dc0217 100644--- a/skyvern/forge/sdk/copilot/terminal_envelope.py+++ b/skyvern/forge/sdk/copilot/terminal_envelope.py@@ -83,12 +83,18 @@ def assemble_terminal_envelope()-def finalize_applied_state(envelope: TerminalOutcomeEnvelope, *, applied: bool) -> TerminalOutcomeEnvelope:+def finalize_applied_state(+ envelope: TerminalOutcomeEnvelope, *, applied: bool, proposal_present: bool = False+) -> TerminalOutcomeEnvelope:if envelope.user_action_required:next_state: TerminalNextState = "awaiting_user_input"elif envelope.verified and applied:next_state = "completed"- elif envelope.next_state == "proposal_pending":+ # A verified un-applied proposal is pending review even though its+ # auto_applicable disposition would otherwise fall through to "stopped":+ # verified fixes no longer auto-commit. Unverified builds keep the+ # built-unverified stop.+ elif envelope.next_state == "proposal_pending" or (proposal_present and not applied and envelope.verified):next_state = "proposal_pending"else:next_state = "stopped"diff --git a/skyvern/forge/sdk/routes/workflow_copilot.py b/skyvern/forge/sdk/routes/workflow_copilot.pyindex 4e8a1b92c..5a60e91b8 100644--- a/skyvern/forge/sdk/routes/workflow_copilot.py+++ b/skyvern/forge/sdk/routes/workflow_copilot.py@@ -403,10 +403,15 @@ def _proposal_disposition(agent_result: object | None) -> ProposalDisposition:def _effective_auto_accept(auto_accept: bool | None, agent_result: object | None) -> bool:- """Only auto-applicable proposals may honor ``auto_accept=True``."""+ """Only auto-applicable proposals may honor ``auto_accept=True``.++ Auto-apply requires the chat's explicit ``auto_accept`` opt-in — a verified+ build never commits on the user's behalf; it lands as a pending proposal for+ the review gate.+ """if getattr(agent_result, "cancelled", False) is True or _proposal_disposition(agent_result) != "auto_applicable":return False- return auto_accept is True or getattr(agent_result, "apply_without_review", False) is True+ return auto_accept is Truedef _should_restore_persisted_workflow(auto_accept: bool | None, agent_result: object | None) -> bool:@@ -513,6 +518,7 @@ def _finalized_terminal_envelope(finalized = finalize_applied_state(TerminalOutcomeEnvelope.model_validate(payload),applied=workflow_applied and proposal_present,+ proposal_present=proposal_present,)payload = finalized.model_dump(mode="json")except Exception:@@ -725,18 +731,13 @@ async def _persist_proposed_workflow_state((restored and not keep_pending_proposal)or agent_result.clear_proposed_workflowor _should_commit_staged_workflow(chat.auto_accept, agent_result)- or (- getattr(agent_result, "apply_without_review", False) is True- and auto_accept_effective- and not _output_policy_blocked_final_response(agent_result)- )):# Null any persisted proposed_workflow the assistant just invalidated# so a reload does not resurrect a stale Accept/Reject card. Runs# under both auto_accept values — a stale proposal can survive an# auto-accept toggle. The staged-commit clause always wins over- # keep_pending_proposal: this turn's own auto-commit already- # overwrote canonical, so an earlier bypassed proposal is now stale+ # keep_pending_proposal: this turn's own auto-accept commit already+ # overwrote canonical, so an earlier pending proposal is now stale# regardless of the client's preservation request.await _clear_proposed_workflow(chat)elif (diff --git a/tests/unit/test_copilot_agent_helpers.py b/tests/unit/test_copilot_agent_helpers.pyindex fe82d4e72..8fae45352 100644--- a/tests/unit/test_copilot_agent_helpers.py+++ b/tests/unit/test_copilot_agent_helpers.py@@ -1623,7 +1623,6 @@ class TestVerifiedGoalSatisfiedStop:assert result.updated_workflow is workflowassert result.workflow_yaml == "workflow_definition:\n blocks: []\n"assert result.proposal_disposition == "review_tested"- assert result.apply_without_review is False# No adjudicated outcome evidence: the turn ends but the claim renders# built-but-unverified instead of a tested-success claim.assert "not independently verified" in result.user_response.lower()@@ -1678,7 +1677,6 @@ class TestVerifiedGoalSatisfiedStop:assert result.updated_workflow is workflowassert result.proposal_disposition == "review_tested"- assert result.apply_without_review is Falseassert "not independently verified" in result.user_response.lower()assert result.turn_outcome is not Noneassert result.turn_outcome.terminal_reason == BUILT_UNVERIFIED_REPAIR_INERT_TERMINAL_REASON@@ -2694,11 +2692,10 @@ class TestTranslateToAgentResultGating:assert verified_goal_claim_authorized(ctx) is Falseassert agent_result.updated_workflow is workflowassert agent_result.proposal_disposition == "review_tested"- assert agent_result.apply_without_review is Falseassert agent_result.narrative_payload is not Noneassert agent_result.narrative_payload["verifiedSuccess"] is False- def test_wip_exit_verified_claim_still_auto_applies_code_only(self) -> None:+ def test_wip_exit_verified_claim_yields_auto_applicable_proposal_code_only(self) -> None:from skyvern.forge.sdk.copilot.config import BlockAuthoringPolicyworkflow = SimpleNamespace(workflow_definition=SimpleNamespace(blocks=[]))@@ -2730,7 +2727,6 @@ class TestTranslateToAgentResultGating:assert verified_goal_claim_authorized(ctx) is Trueassert agent_result.updated_workflow is workflowassert agent_result.proposal_disposition == "auto_applicable"- assert agent_result.apply_without_review is Truedef test_output_field_confirmation_question_is_blocked_when_contract_present(self) -> None:ctx = _ctx(@@ -3495,9 +3491,8 @@ workflow_definition:assert agent_result.updated_workflow is wfassert agent_result.proposal_disposition == "auto_applicable"- assert agent_result.apply_without_review is False- def test_code_only_verified_build_applies_without_review(self) -> None:+ def test_code_only_verified_build_yields_auto_applicable_proposal(self) -> None:from skyvern.forge.sdk.copilot.config import BlockAuthoringPolicywf = SimpleNamespace(name="drafted")@@ -3525,7 +3520,6 @@ workflow_definition:assert agent_result.updated_workflow is wfassert agent_result.proposal_disposition == "auto_applicable"- assert agent_result.apply_without_review is Truedef test_goal_reached_string_false_is_coerced(self) -> None:# LLMs occasionally emit JSON-as-string values; ``"false"`` must flipdiff --git a/tests/unit/test_copilot_completion_zero_run_plane.py b/tests/unit/test_copilot_completion_zero_run_plane.pyindex 288e835dc..9ab3397d5 100644--- a/tests/unit/test_copilot_completion_zero_run_plane.py+++ b/tests/unit/test_copilot_completion_zero_run_plane.py@@ -6,7 +6,6 @@ from typing import Anyimport pytest-from skyvern.forge.sdk.copilot.agent import _should_apply_code_only_success_without_reviewfrom skyvern.forge.sdk.copilot.completion_criteria_store import (CompletionCriteriaTurnState,note_adjudication_on_turn_state,@@ -16,7 +15,6 @@ from skyvern.forge.sdk.copilot.completion_verification import (CriterionVerdict,combine_verification_results,)-from skyvern.forge.sdk.copilot.config import BlockAuthoringPolicyfrom skyvern.forge.sdk.copilot.context import CopilotContextfrom skyvern.forge.sdk.copilot.request_policy import RequestPolicyfrom skyvern.forge.sdk.copilot.run_outcome import RecordedRunOutcome@@ -357,18 +355,3 @@ def test_rollback_anchor_not_recorded_for_definition_only_contract() -> None:note_adjudication_on_turn_state(turn_state, verification, fully_satisfied_workflow_yaml="x: y")assert turn_state.fully_satisfied_workflow_yaml is None---def test_gated_state_does_not_auto_apply_code_only_success() -> None:- ctx = _ctx()- ctx.request_policy = RequestPolicy(completion_criteria=[], classifier_status="fallback")- ctx.completion_verification_result = CompletionVerificationResult(- status="evaluated", criterion_ids=[], verdicts=[], no_gradeable_run_plane=True- )- ctx.block_authoring_policy = BlockAuthoringPolicy.CODE_ONLY_BROWSER- ctx.has_staged_proposal = True- ctx.staged_workflow = SimpleNamespace() # type: ignore[assignment]- ctx.last_test_ok = True- ctx.last_full_workflow_test_ok = False-- assert _should_apply_code_only_success_without_review(ctx, "auto_applicable") is Falsediff --git a/tests/unit/test_copilot_terminal_envelope.py b/tests/unit/test_copilot_terminal_envelope.pyindex 72ec52f61..6eb440d51 100644--- a/tests/unit/test_copilot_terminal_envelope.py+++ b/tests/unit/test_copilot_terminal_envelope.py@@ -187,6 +187,22 @@ def test_finalize_applied_state_blocks_completed_when_not_applied() -> None:assert finalized.response_kind == "stopped"+def test_finalize_applied_state_marks_unapplied_proposal_pending() -> None:+ # A verified code-only fix is auto_applicable but no longer auto-commits; when+ # not applied it must render as a pending proposal (ReviewGateCard), not stopped.+ envelope = _assemble(verified=True, workflow_applied=False, proposal_disposition="auto_applicable")+ assert envelope.next_state == "stopped"++ finalized = finalize_applied_state(envelope, applied=False, proposal_present=True)++ assert finalized.workflow_applied is False+ assert finalized.next_state == "proposal_pending"+ assert finalized.response_kind == "update"++ # No proposal present (a genuine stop) stays stopped.+ assert finalize_applied_state(envelope, applied=False).next_state == "stopped"++def test_finalize_applied_state_keeps_question_for_user_action_required() -> None:envelope = _assemble(response_type="ASK_QUESTION", verified=True, workflow_applied=False, proposal_disposition="no_proposal"diff --git a/tests/unit/test_workflow_copilot_route.py b/tests/unit/test_workflow_copilot_route.pyindex 94249c095..408329b44 100644--- a/tests/unit/test_workflow_copilot_route.py+++ b/tests/unit/test_workflow_copilot_route.py@@ -164,16 +164,17 @@ async def test_finalise_normal_turn_finalizes_terminal_envelope_without_auto_accassert isinstance(response_frame, WorkflowCopilotStreamResponseUpdate)assert response_frame.terminal_envelope is not Noneassert response_frame.terminal_envelope["workflow_applied"] is False- assert response_frame.terminal_envelope["next_state"] != "completed"- assert response_frame.terminal_envelope["response_kind"] == "stopped"+ # Verified fix, not auto-accepted: a pending proposal for the review gate, not stopped.+ assert response_frame.terminal_envelope["next_state"] == "proposal_pending"+ assert response_frame.terminal_envelope["response_kind"] == "update"persisted_payload = workflow_params.create_workflow_copilot_chat_message.await_args_list[-1].kwargs["narrative_payload"]assert persisted_payload is not Noneassert persisted_payload["terminalEnvelope"]["workflow_applied"] is False- assert persisted_payload["terminalEnvelope"]["next_state"] != "completed"- assert persisted_payload["terminalEnvelope"]["response_kind"] == "stopped"+ assert persisted_payload["terminalEnvelope"]["next_state"] == "proposal_pending"+ assert persisted_payload["terminalEnvelope"]["response_kind"] == "update"@pytest.mark.asyncio@@ -2190,9 +2191,13 @@ async def test_proposed_workflow_cleared_on_restore(@pytest.mark.asyncio-async def test_apply_without_review_commits_and_clears_proposal_when_auto_accept_off(+async def test_verified_code_only_fix_stays_pending_without_auto_accept(monkeypatch: pytest.MonkeyPatch,) -> None:+ # With auto_accept off, a verified CODE_ONLY_BROWSER fix (auto_applicable + staged)+ # must stay a pending proposal: no canonical commit, proposal persisted, terminal+ # frame reports workflow_applied False. ``apply_without_review`` is set truthy only+ # to prove that attribute can no longer force an auto-apply on its own.monkeypatch.setattr(settings, "ENABLE_WORKFLOW_COPILOT_V2", True)captured = install_fake_create(monkeypatch)@@ -2271,10 +2276,11 @@ async def test_apply_without_review_commits_and_clears_proposal_when_auto_acceptawait handler(stream)restore_mock.assert_not_awaited()- workflow_service.update_workflow_definition.assert_awaited_once()+ workflow_service.update_workflow_definition.assert_not_awaited()update_calls = app.DATABASE.workflow_params.update_workflow_copilot_chat.await_args_list- assert [c for c in update_calls if c.kwargs.get("proposed_workflow") is not None] == []- assert [c for c in update_calls if c.kwargs.get("proposed_workflow") is None]+ proposed_writes = [c.kwargs["proposed_workflow"] for c in update_calls if "proposed_workflow" in c.kwargs]+ assert proposed_writes, "expected the pending proposal to be persisted"+ assert all(w is not None for w in proposed_writes), "verified fix must stay pending, not be cleared"response_frames = [call.args[0]@@ -2282,7 +2288,7 @@ async def test_apply_without_review_commits_and_clears_proposal_when_auto_acceptif isinstance(call.args[0], WorkflowCopilotStreamResponseUpdate)]assert len(response_frames) == 1- assert response_frames[0].workflow_applied is True+ assert response_frames[0].workflow_applied is Falseassert response_frames[0].updated_workflow == {"workflow_id": "wf-applied"}@@ -2643,7 +2649,6 @@ async def test_persist_state_keeps_verified_review_tested_proposal(monkeypatch:clear_proposed_workflow=False,proposal_disposition="review_tested",cancelled=False,- apply_without_review=False,output_policy_diagnostics=None,canonical_was_persisted_due_to_param_change=False,)@@ -2663,7 +2668,6 @@ def _make_bypassed_proposal_agent_result(**overrides: object) -> SimpleNamespaceclear_proposed_workflow=False,proposal_disposition="review_untested",cancelled=False,- apply_without_review=False,output_policy_diagnostics=None,)fields.update(overrides)@@ -2835,9 +2839,9 @@ async def test_persist_state_auto_accept_stale_unvalidated_still_clears_without_async def test_persist_state_staged_commit_clears_stale_proposal_despite_keep_pending(monkeypatch: pytest.MonkeyPatch,) -> None:- # A later turn's own auto-commit (chat.auto_accept, not apply_without_review)- # supersedes an earlier bypassed proposal even when the client asked to keep- # it — the committed canonical workflow already moved past it.+ # A later turn's own auto-accept commit (chat.auto_accept) supersedes an+ # earlier pending proposal even when the client asked to keep it — the+ # committed canonical workflow already moved past it.chat = SimpleNamespace(organization_id="org-1",workflow_copilot_chat_id="chat-1",diff --git a/tests/unit/test_workflow_copilot_route_helpers.py b/tests/unit/test_workflow_copilot_route_helpers.pyindex 5cdbf7b93..20b77239c 100644--- a/tests/unit/test_workflow_copilot_route_helpers.py+++ b/tests/unit/test_workflow_copilot_route_helpers.py@@ -46,7 +46,6 @@ def _agent_result(r.proposal_disposition = proposal_dispositionr.cancelled = cancelledr.updated_workflow = updated_workflow- r.apply_without_review = kwargs.pop("apply_without_review", False)# SKY-10318: explicitly set the new staging flag so MagicMock truthiness# doesn't accidentally trigger the degraded-path branch in# `_should_restore_persisted_workflow`.@@ -116,20 +115,22 @@ class TestEffectiveAutoAccept:validated = MagicMock()validated.proposal_disposition = "auto_applicable"validated.cancelled = False- validated.apply_without_review = Falseassert _effective_auto_accept(True, validated) is Trueassert _effective_auto_accept(False, validated) is Falseassert _effective_auto_accept(None, validated) is False- def test_apply_without_review_overrides_auto_accept_setting(self) -> None:+ def test_verified_fix_does_not_auto_apply_without_explicit_auto_accept(self) -> None:+ # Only the chat's explicit ``auto_accept`` opt-in may auto-apply an+ # auto_applicable proposal; a truthy ``apply_without_review`` attribute+ # must not force an auto-apply on its own.validated = MagicMock()validated.proposal_disposition = "auto_applicable"validated.cancelled = Falsevalidated.apply_without_review = True- assert _effective_auto_accept(False, validated) is True- assert _effective_auto_accept(None, validated) is True+ assert _effective_auto_accept(False, validated) is False+ assert _effective_auto_accept(None, validated) is Falsedef test_no_agent_result_is_not_auto_applicable(self) -> None:assert _proposal_disposition(None) == "no_proposal"