Skip to content

Automate browser based workflows with AI

Fix mislabeled enforcement telemetry and trim 366 redundant copilot tests (#8077)

Andrew Neilsonab3744a62427
diff --git a/skyvern/forge/sdk/copilot/output_policy.py b/skyvern/forge/sdk/copilot/output_policy.py
index f8341e218..55fe72030 100644
--- a/skyvern/forge/sdk/copilot/output_policy.py
+++ b/skyvern/forge/sdk/copilot/output_policy.py
@@ -1005,11 +1005,11 @@ def _bound_approved_credential_ids(request_policy: RequestPolicy, workflow_yaml:
def _allowed_unresolved_credential_ids(request_policy: RequestPolicy) -> set[str]:
+ # invalid_credential_ids is negation-filtered and affirmative; credential_refs is not — a
+ # model-carried or negated ref must not become draft-bindable (SKY-13552).
if not request_policy.allow_missing_credentials_in_draft:
return set()
- ids = set(request_policy.invalid_credential_ids)
- ids.update(ref for ref in request_policy.credential_refs if isinstance(ref, str) and ref.startswith("cred_"))
- return ids
+ return set(request_policy.invalid_credential_ids)
def _existing_workflow_credential_ids(request_policy: RequestPolicy) -> set[str]:
diff --git a/tests/unit/test_copilot_output_policy.py b/tests/unit/test_copilot_output_policy.py
index 8ff068752..b917c3128 100644
--- a/tests/unit/test_copilot_output_policy.py
+++ b/tests/unit/test_copilot_output_policy.py
@@ -1240,6 +1240,24 @@ def test_allows_explicit_unresolved_credential_id_for_untested_draft() -> None:
assert verdict.allowed
+def test_rejects_credential_ref_the_user_did_not_state_even_for_untested_draft() -> None:
+ """A cred_ ref carried only in credential_refs (model-authored or negated) is not draft-bindable (SKY-13552)."""
+ verdict = evaluate_output_policy(
+ request_policy=_policy(
+ resolved_credentials=[],
+ credential_input_kind="credential_id",
+ credential_refs=["cred_carried"],
+ invalid_credential_ids=[],
+ allow_missing_credentials_in_draft=True,
+ allow_run_blocks=False,
+ ),
+ workflow_yaml=_workflow_yaml().replace("cred_safe", "cred_carried"),
+ )
+
+ assert not verdict.allowed
+ assert OutputPolicyReason.UNAPPROVED_CREDENTIAL_REFERENCE in verdict.reason_codes
+
+
def test_rejects_unrequested_credential_id_even_when_untested_draft_allows_missing_credentials() -> None:
verdict = evaluate_output_policy(
request_policy=_policy(