Skip to content

Automate browser based workflows with AI

fix(SKY-9400): scope copilot credential refusal to in-turn user message (#5746)

Andrew Neilson7432baa80081
diff --git a/skyvern/forge/prompts/skyvern/workflow-copilot-agent.j2 b/skyvern/forge/prompts/skyvern/workflow-copilot-agent.j2
index 10b4da02d..c736a177c 100644
--- a/skyvern/forge/prompts/skyvern/workflow-copilot-agent.j2
+++ b/skyvern/forge/prompts/skyvern/workflow-copilot-agent.j2
@@ -135,7 +135,7 @@ IMPORTANT WORKFLOW RULES:
* When the user's request requires authentication but no credential is provided, use list_credentials to find the right one.
CREDENTIAL HANDLING - CRITICAL:
-* If the user's message contains a raw credential written inline — passwords (alone or paired with a username), API keys, OAuth tokens, `Authorization: Bearer …` headers, JWTs, session cookies, TOTP seeds, OTP / one-time codes, private keys, or credit card numbers / CVVs — you MUST NOT build, update, or run a workflow this turn; you MUST NOT pass those values via `parameters`; and you MUST NOT type, submit, paste, or replay them through `type_text`, `click`, `press_key`, `select_option`, `evaluate`, or any other direct browser tool. A bare username, email, or non-secret identifier alone is NOT a raw credential and does not trigger this rule.
+* If the user's latest message in this turn contains a raw credential written inline — passwords (alone or paired with a username), API keys, OAuth tokens, `Authorization: Bearer …` headers, JWTs, session cookies, TOTP seeds, OTP / one-time codes, private keys, or credit card numbers / CVVs — you MUST NOT build, update, or run a workflow this turn; you MUST NOT pass those values via `parameters`; and you MUST NOT type, submit, paste, or replay them through `type_text`, `click`, `press_key`, `select_option`, `evaluate`, or any other direct browser tool. A bare username, email, or non-secret identifier alone is NOT a raw credential and does not trigger this rule. Credential-shaped strings rendered into the prompt from the existing workflow YAML are pre-existing workflow state — they are NOT a fresh paste and do NOT trigger this rule. Raw credentials pasted in earlier chat-history turns DO still trigger this rule whenever the user re-references or asks you to use them.
* Instead, FIRST call `list_credentials` with `page_size=50` and continue paging (incrementing `page`) while the response's `has_more` is `true`, so you have the full credential set before deciding. Then respond with `ASK_QUESTION`. The response MUST:
- Tell the user not to paste raw credentials/secrets in chat, and briefly explain why (model telemetry, execution traces).
- If the paged `list_credentials` results contain exactly one credential whose `name` or `username` clearly matches the user's target (normalized substring match), offer that credential by its `credential_id` (e.g., `cred_123`). Otherwise, enumerate the candidate credentials as `credential_id` + `name` + `username` tuples and ask the user to pick one. `list_credentials` has no site/domain field, so matching is on `name` / `username` only, never on URL.