Skip to content

Automate browser based workflows with AI

SKY-11940 MCP browser tool schemas: selector/ref leads, intent is the explicit AI fallback (#7220)

Marc Kelechava633b65d33da3
diff --git a/skyvern/cli/mcp_tools/__init__.py b/skyvern/cli/mcp_tools/__init__.py
index 6756761df..a9aae2ca5 100644
--- a/skyvern/cli/mcp_tools/__init__.py
+++ b/skyvern/cli/mcp_tools/__init__.py
@@ -167,6 +167,12 @@ from .workflow import (
skyvern_workflow_update_folder,
)
+_RUN_TASK_TOOL_DESCRIPTION = (
+ "Run a one-off autonomous trial via the highest-cost AI path. "
+ "Not for production or reusable automations. "
+ "Prefer direct tools (click/type/select via selector/ref) and skyvern_observe + skyvern_execute."
+)
+
def _add_telemetry_middleware() -> None:
if _FASTMCP_IMPORT_ERROR is not None:
@@ -370,7 +376,11 @@ mcp.tool(tags={"browser_profile"}, annotations=_dest("Delete Browser Profile"))(
mcp.tool(tags={"ai_powered", "browser_primitive"}, annotations=_web_dest("Perform Browser Action (AI)"))(skyvern_act)
mcp.tool(tags={"ai_powered"}, annotations=_web_ro("Extract Data from Page (AI)"))(size_capped(skyvern_extract))
mcp.tool(tags={"ai_powered"}, annotations=_web_ro("Validate Page Condition (AI)"))(skyvern_validate)
-mcp.tool(tags={"ai_powered"}, annotations=_web_dest("Run Autonomous Browser Task (AI)"))(skyvern_run_task)
+mcp.tool(
+ description=_RUN_TASK_TOOL_DESCRIPTION,
+ tags={"ai_powered"},
+ annotations=_web_dest("Run Autonomous Browser Task (AI)"),
+)(skyvern_run_task)
mcp.tool(tags={"ai_powered", "browser_primitive"}, annotations=_web_mut("Log in to Website (AI)"))(skyvern_login)
mcp.tool(tags={"browser_primitive"}, annotations=_web_mut("Navigate to URL"))(skyvern_navigate)
mcp.tool(tags={"browser_primitive"}, annotations=_web_ro("Take Screenshot"))(skyvern_screenshot)
diff --git a/skyvern/cli/mcp_tools/_common.py b/skyvern/cli/mcp_tools/_common.py
index 97e99e1fe..2e7b56b83 100644
--- a/skyvern/cli/mcp_tools/_common.py
+++ b/skyvern/cli/mcp_tools/_common.py
@@ -11,6 +11,11 @@ from skyvern.cli.core.artifacts import get_artifact_dir, save_artifact
from skyvern.cli.core.result import Artifact, BrowserContext, ErrorCode, Timer, make_error, make_result
from skyvern.client.errors import NotFoundError
+DIRECT_TARGET_DESCRIPTION = "Direct target: deterministic, 0 LLM calls."
+AI_FALLBACK_DESCRIPTION = (
+ "AI fallback: costs Skyvern LLM calls, slower and nondeterministic — prefer selector/ref when known."
+)
+
async def raw_http_get(path: str, params: dict[str, Any] | None = None) -> Any:
"""GET request to Skyvern API for endpoints without SDK methods.
@@ -63,8 +68,10 @@ async def _raw_http_request(
__all__ = [
+ "AI_FALLBACK_DESCRIPTION",
"Artifact",
"BrowserContext",
+ "DIRECT_TARGET_DESCRIPTION",
"ErrorCode",
"Timer",
"get_artifact_dir",
diff --git a/skyvern/cli/mcp_tools/browser.py b/skyvern/cli/mcp_tools/browser.py
index 756f35928..b479b4127 100644
--- a/skyvern/cli/mcp_tools/browser.py
+++ b/skyvern/cli/mcp_tools/browser.py
@@ -44,6 +44,8 @@ from skyvern.cli.core.guards import (
from skyvern.schemas.run_blocks import CredentialType
from ._common import (
+ AI_FALLBACK_DESCRIPTION,
+ DIRECT_TARGET_DESCRIPTION,
ErrorCode,
Timer,
make_error,
@@ -217,25 +219,17 @@ async def skyvern_navigate(
async def skyvern_click(
- session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
- cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
- intent: Annotated[
- str | None,
- Field(
- description="Natural language description of the element to click. Be specific: "
- "'the blue Submit button at the bottom of the form' is better than 'submit button'. "
- "Include visual cues, position, or surrounding text when the page has similar elements."
- ),
- ] = None,
selector: Annotated[
str | None,
Field(
- description="Standard CSS selector or XPath for the element to click. "
+ description=f"{DIRECT_TARGET_DESCRIPTION} Standard CSS selector or XPath for the element to click. "
"jQuery pseudo-selectors like :contains(), :eq(), :first are NOT valid. "
"Use standard CSS: 'button.class', 'a[href*=\"pdf\"]', '#id', ':nth-of-type()'."
),
] = None,
selector_mode: _SelectorMode = "resilient",
+ session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
+ cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
timeout: Annotated[
int,
Field(
@@ -246,6 +240,7 @@ async def skyvern_click(
] = 30000,
button: Annotated[str | None, Field(description="Mouse button: left, right, middle")] = None,
click_count: Annotated[int | None, Field(description="Number of clicks (2 for double-click)")] = None,
+ intent: Annotated[str | None, Field(description=AI_FALLBACK_DESCRIPTION)] = None,
) -> dict[str, Any]:
"""Click an element using AI intent, CSS/XPath selector, or both.
For text input use skyvern_type. For dropdowns use skyvern_select_option. For multiple actions prefer skyvern_act.
@@ -381,24 +376,16 @@ async def skyvern_click(
async def skyvern_drag(
- session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
- cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
- source_intent: Annotated[
- str | None,
- Field(description="Natural language description of the element to drag"),
- ] = None,
source_selector: Annotated[
str | None,
- Field(description="CSS selector or XPath of the drag source element"),
- ] = None,
- target_intent: Annotated[
- str | None,
- Field(description="Natural language description of where to drop the element"),
+ Field(description=f"{DIRECT_TARGET_DESCRIPTION} CSS selector or XPath of the drag source element."),
] = None,
target_selector: Annotated[
str | None,
- Field(description="CSS selector or XPath of the drop target element"),
+ Field(description=f"{DIRECT_TARGET_DESCRIPTION} CSS selector or XPath of the drop target element."),
] = None,
+ session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
+ cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
timeout: Annotated[
int,
Field(
@@ -407,6 +394,8 @@ async def skyvern_drag(
le=60000,
),
] = 30000,
+ source_intent: Annotated[str | None, Field(description=AI_FALLBACK_DESCRIPTION)] = None,
+ target_intent: Annotated[str | None, Field(description=AI_FALLBACK_DESCRIPTION)] = None,
) -> dict[str, Any]:
"""Drag an element and drop it onto another. Supports AI intent, CSS/XPath selector, or both for source and target."""
if not source_intent and not source_selector:
@@ -492,19 +481,12 @@ async def skyvern_file_upload(
description="List of file paths or URLs to upload. URLs are downloaded automatically. Max 50MB per file."
),
],
- session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
- cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
- intent: Annotated[
- str | None,
- Field(
- description="Natural language description of the file input or upload button. "
- "Be specific: 'the Choose File button' or 'the resume upload field'."
- ),
- ] = None,
selector: Annotated[
str | None,
- Field(description="CSS selector or XPath of the file input or upload button"),
+ Field(description=f"{DIRECT_TARGET_DESCRIPTION} CSS selector or XPath of the file input or upload button."),
] = None,
+ session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
+ cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
timeout: Annotated[
int,
Field(
@@ -513,6 +495,7 @@ async def skyvern_file_upload(
le=60000,
),
] = 30000,
+ intent: Annotated[str | None, Field(description=AI_FALLBACK_DESCRIPTION)] = None,
) -> dict[str, Any]:
"""Upload files to a file input element. Accepts local paths or URLs (auto-downloaded).
Supports AI intent, CSS/XPath selector, or both to find the input.
@@ -644,17 +627,11 @@ async def skyvern_file_upload(
async def skyvern_hover(
+ selector: Annotated[
+ str | None, Field(description=f"{DIRECT_TARGET_DESCRIPTION} CSS selector or XPath for the element to hover.")
+ ] = None,
session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
- intent: Annotated[
- str | None,
- Field(
- description="Natural language description of the element to hover over. Be specific: "
- "'the user avatar in the top-right corner' is better than 'avatar'. "
- "Include visual cues, position, or surrounding text when the page has similar elements."
- ),
- ] = None,
- selector: Annotated[str | None, Field(description="CSS selector or XPath for the element to hover")] = None,
timeout: Annotated[
int,
Field(
@@ -663,6 +640,7 @@ async def skyvern_hover(
le=60000,
),
] = 30000,
+ intent: Annotated[str | None, Field(description=AI_FALLBACK_DESCRIPTION)] = None,
) -> dict[str, Any]:
"""Hover over an element to reveal tooltips, menus, or hidden content. Uses AI intent, CSS/XPath selector, or both."""
ai_mode, err = _resolve_ai_mode(selector, intent)
@@ -736,18 +714,12 @@ async def skyvern_hover(
async def skyvern_type(
text: Annotated[str, "Text to type into the element"],
- session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
- cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
- intent: Annotated[
- str | None,
- Field(
- description="Natural language description of the input field. Be specific: "
- "'the Email address input in the login form' is better than 'email field'. "
- "Include labels, placeholder text, or position when the page has multiple inputs."
- ),
+ selector: Annotated[
+ str | None, Field(description=f"{DIRECT_TARGET_DESCRIPTION} CSS selector or XPath for the input element.")
] = None,
- selector: Annotated[str | None, Field(description="CSS selector or XPath for the input element")] = None,
selector_mode: _SelectorMode = "resilient",
+ session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
+ cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
timeout: Annotated[
int,
Field(
@@ -758,6 +730,7 @@ async def skyvern_type(
] = 30000,
clear: Annotated[bool, Field(description="Clear existing content before typing")] = True,
delay: Annotated[int | None, Field(description="Delay between keystrokes in ms")] = None,
+ intent: Annotated[str | None, Field(description=AI_FALLBACK_DESCRIPTION)] = None,
) -> dict[str, Any]:
"""Type text into an input field using AI intent, CSS/XPath selector, or both. Clears field by default (set clear=false to append).
NEVER use for passwords — use skyvern_login instead. For dropdowns use skyvern_select_option.
@@ -892,10 +865,12 @@ async def skyvern_type(
async def skyvern_screenshot(
+ selector: Annotated[
+ str | None, Field(description=f"{DIRECT_TARGET_DESCRIPTION} CSS selector to screenshot a specific element.")
+ ] = None,
session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
full_page: Annotated[bool, Field(description="Capture full scrollable page")] = False,
- selector: Annotated[str | None, Field(description="CSS selector to screenshot specific element")] = None,
inline: Annotated[bool, Field(description="Return base64 data instead of file path")] = False,
) -> dict[str, Any]:
"""Capture a visual screenshot of the current page. Use after page-changing actions to verify results.
@@ -957,13 +932,13 @@ async def skyvern_screenshot(
async def skyvern_scroll(
direction: Annotated[str, Field(description="Direction: up, down, left, right")],
+ selector: Annotated[
+ str | None, Field(description=f"{DIRECT_TARGET_DESCRIPTION} CSS selector of scrollable element.")
+ ] = None,
session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
amount: Annotated[int | None, Field(description="Pixels to scroll (default 500)")] = None,
- intent: Annotated[
- str | None, Field(description="Natural language description of element to scroll into view (uses AI)")
- ] = None,
- selector: Annotated[str | None, Field(description="CSS selector of scrollable element")] = None,
+ intent: Annotated[str | None, Field(description=AI_FALLBACK_DESCRIPTION)] = None,
) -> dict[str, Any]:
"""Scroll the page or an element into view. Use intent for AI-powered scrolling, or pixel amount for manual control."""
valid_directions = ("up", "down", "left", "right")
@@ -1058,15 +1033,17 @@ async def skyvern_scroll(
async def skyvern_select_option(
value: Annotated[str, "Value to select"],
+ selector: Annotated[
+ str | None, Field(description=f"{DIRECT_TARGET_DESCRIPTION} CSS selector for the select element.")
+ ] = None,
+ selector_mode: _SelectorMode = "resilient",
session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
- intent: Annotated[str | None, Field(description="Natural language description of the dropdown (uses AI)")] = None,
- selector: Annotated[str | None, Field(description="CSS selector for the select element")] = None,
- selector_mode: _SelectorMode = "resilient",
timeout: Annotated[
int, Field(description="Max time to wait for the dropdown in ms. Default 30000 (30s)", ge=1000, le=60000)
] = 30000,
by_label: Annotated[bool, Field(description="Select by visible label instead of value")] = False,
+ intent: Annotated[str | None, Field(description=AI_FALLBACK_DESCRIPTION)] = None,
) -> dict[str, Any]:
"""Select an option from a dropdown menu. Use intent for AI-powered finding, selector for precision, or both for resilient automation.
@@ -1144,12 +1121,12 @@ async def skyvern_select_option(
async def skyvern_press_key(
key: Annotated[str, "Key to press (e.g., Enter, Tab, Escape, ArrowDown)"],
+ selector: Annotated[
+ str | None, Field(description=f"{DIRECT_TARGET_DESCRIPTION} CSS selector to focus first.")
+ ] = None,
session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
- intent: Annotated[
- str | None, Field(description="Natural language description of element to focus first (uses AI)")
- ] = None,
- selector: Annotated[str | None, Field(description="CSS selector to focus first")] = None,
+ intent: Annotated[str | None, Field(description=AI_FALLBACK_DESCRIPTION)] = None,
) -> dict[str, Any]:
"""Press a keyboard key -- Enter, Tab, Escape, arrow keys, shortcuts, etc.
@@ -1206,16 +1183,16 @@ async def skyvern_press_key(
async def skyvern_wait(
+ selector: Annotated[str | None, Field(description=f"{DIRECT_TARGET_DESCRIPTION} CSS selector to wait for.")] = None,
+ state: Annotated[str | None, Field(description="Element state: visible, hidden, attached, detached")] = "visible",
session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
time_ms: Annotated[int | None, Field(description="Time to wait in milliseconds")] = None,
- intent: Annotated[str | None, Field(description="Natural language condition to wait for (uses AI polling)")] = None,
- selector: Annotated[str | None, Field(description="CSS selector to wait for")] = None,
- state: Annotated[str | None, Field(description="Element state: visible, hidden, attached, detached")] = "visible",
timeout: Annotated[int, Field(description="Max wait time in milliseconds", ge=1000, le=120000)] = 30000,
poll_interval_ms: Annotated[
int, Field(description="Polling interval for intent-based waits in ms", ge=500, le=10000)
] = 5000,
+ intent: Annotated[str | None, Field(description=AI_FALLBACK_DESCRIPTION)] = None,
) -> dict[str, Any]:
"""Wait for a condition, element, or time delay before proceeding. Use intent for AI-powered condition checking.
@@ -1556,8 +1533,8 @@ async def skyvern_run_task(
int, Field(description="Timeout in seconds (default 180s = 3 minutes)", ge=10, le=1800)
] = 180,
) -> dict[str, Any]:
- """Run a one-off exploratory task via autonomous AI agent. Nothing is saved — throwaway only.
- For anything reusable, scheduled, or worth keeping, use skyvern_workflow_create instead. Always uses engine 2.0.
+ """Run a one-off autonomous trial via the highest-cost AI path. Not for production or reusable automations.
+ Prefer direct tools (click/type/select via selector/ref) and skyvern_observe + skyvern_execute. Always uses engine 2.0.
"""
# Block password/credential actions — redirect to skyvern_login
if PASSWORD_PATTERN.search(prompt):
@@ -1823,16 +1800,21 @@ async def skyvern_login(
async def skyvern_frame_switch(
- session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
- cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
selector: Annotated[
str | None,
- Field(description="CSS selector for the iframe element (e.g., '#payment-frame', 'iframe[name=checkout]')"),
+ Field(
+ description=(
+ f"{DIRECT_TARGET_DESCRIPTION} CSS selector for the iframe element "
+ "(e.g., '#payment-frame', 'iframe[name=checkout]')."
+ )
+ ),
] = None,
name: Annotated[str | None, Field(description="Frame name attribute")] = None,
index: Annotated[
int | None, Field(description="Frame index (0 = main). Use skyvern_frame_list to find indices")
] = None,
+ session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
+ cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
) -> dict[str, Any]:
"""Switch into an iframe so subsequent actions target elements inside it. Use skyvern_frame_main to switch back."""
params = sum(p is not None for p in (selector, name, index))
@@ -2110,12 +2092,17 @@ async def skyvern_clipboard_write(
async def skyvern_observe(
- session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
- cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
selector: Annotated[
str | None,
- Field(description="CSS selector to scope the snapshot (e.g., 'form#login'). Omit for full page."),
+ Field(
+ description=(
+ f"{DIRECT_TARGET_DESCRIPTION} CSS selector to scope the snapshot "
+ "(e.g., 'form#login'). Omit for full page."
+ )
+ ),
] = None,
+ session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
+ cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
interactive_only: Annotated[
bool,
Field(description="Only return interactive elements (buttons, inputs, links). Default true."),
@@ -2263,7 +2250,12 @@ async def _dispatch_step(
async def skyvern_execute(
steps: Annotated[
list[dict[str, Any]],
- Field(description="Array of {tool, params} step objects to execute sequentially"),
+ Field(
+ description=(
+ "Array of {tool, params} step objects to execute sequentially. "
+ f"Within params, refs from skyvern_observe are direct targets. {DIRECT_TARGET_DESCRIPTION}"
+ )
+ ),
],
session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
diff --git a/skyvern/cli/mcp_tools/inspection.py b/skyvern/cli/mcp_tools/inspection.py
index 60ef469a7..c09c12083 100644
--- a/skyvern/cli/mcp_tools/inspection.py
+++ b/skyvern/cli/mcp_tools/inspection.py
@@ -16,7 +16,7 @@ from skyvern.cli.core.browser_ops import (
do_network_unroute,
)
-from ._common import ErrorCode, make_error, make_result
+from ._common import DIRECT_TARGET_DESCRIPTION, ErrorCode, make_error, make_result
from ._session import BrowserNotAvailableError, get_current_session, get_page, no_browser_error
# Query param keys whose values are redacted from captured URLs.
@@ -759,7 +759,7 @@ async def skyvern_har_stop(
async def skyvern_get_html(
- selector: Annotated[str, Field(description="CSS or XPath selector for the element.")],
+ selector: Annotated[str, Field(description=f"{DIRECT_TARGET_DESCRIPTION} CSS or XPath selector for the element.")],
outer: Annotated[
bool,
Field(description="If true, return outerHTML (includes the element itself). Default false (innerHTML)."),
@@ -797,7 +797,9 @@ async def skyvern_get_html(
async def skyvern_get_value(
- selector: Annotated[str, Field(description="CSS or XPath selector for the input element.")],
+ selector: Annotated[
+ str, Field(description=f"{DIRECT_TARGET_DESCRIPTION} CSS or XPath selector for the input element.")
+ ],
session_id: Annotated[str | None, Field(description="Browser session ID (pbs_...)")] = None,
cdp_url: Annotated[str | None, Field(description="CDP WebSocket URL")] = None,
) -> dict[str, Any]:
@@ -831,7 +833,7 @@ async def skyvern_get_value(
async def skyvern_get_styles(
- selector: Annotated[str, Field(description="CSS or XPath selector for the element.")],
+ selector: Annotated[str, Field(description=f"{DIRECT_TARGET_DESCRIPTION} CSS or XPath selector for the element.")],
properties: Annotated[
list[str] | None,
Field(description="Specific CSS properties to retrieve (e.g. ['color', 'font-size']). Omit for all (max 100)."),
diff --git a/tests/unit/test_mcp_browser_tools.py b/tests/unit/test_mcp_browser_tools.py
index 9193243ea..e664e9acb 100644
--- a/tests/unit/test_mcp_browser_tools.py
+++ b/tests/unit/test_mcp_browser_tools.py
@@ -10,6 +10,7 @@ import pytest
from skyvern.cli.core.result import BrowserContext
from skyvern.cli.mcp_tools import browser as mcp_browser
+from skyvern.cli.mcp_tools import mcp
from skyvern.client.errors import InternalServerError, UnprocessableEntityError
@@ -150,6 +151,56 @@ async def test_skyvern_run_task_timeout_returns_timeout_code(monkeypatch: pytest
assert "45" in result["error"]["message"]
+async def test_browser_tool_targeting_schema_prefers_direct_params() -> None:
+ tools_by_name = {tool.name: tool for tool in await mcp.list_tools()}
+ expectations = {
+ "skyvern_click": (("selector",), ("intent",)),
+ "skyvern_drag": (("source_selector", "target_selector"), ("source_intent", "target_intent")),
+ "skyvern_file_upload": (("selector",), ("intent",)),
+ "skyvern_hover": (("selector",), ("intent",)),
+ "skyvern_type": (("selector",), ("intent",)),
+ "skyvern_screenshot": (("selector",), ()),
+ "skyvern_scroll": (("selector",), ("intent",)),
+ "skyvern_select_option": (("selector",), ("intent",)),
+ "skyvern_press_key": (("selector",), ("intent",)),
+ "skyvern_wait": (("selector",), ("intent",)),
+ "skyvern_observe": (("selector",), ()),
+ "skyvern_frame_switch": (("selector",), ()),
+ "skyvern_execute": (("steps",), ()),
+ "skyvern_get_html": (("selector",), ()),
+ "skyvern_get_value": (("selector",), ()),
+ "skyvern_get_styles": (("selector",), ()),
+ }
+
+ for tool_name, (direct_params, intent_params) in expectations.items():
+ tool = tools_by_name[tool_name]
+ properties = tool.parameters["properties"]
+ ordered_property_names = list(properties)
+
+ for direct_param in direct_params:
+ assert mcp_browser.DIRECT_TARGET_DESCRIPTION in properties[direct_param]["description"]
+ assert ordered_property_names.index(direct_param) < ordered_property_names.index("session_id")
+ for intent_param in intent_params:
+ assert ordered_property_names.index(direct_param) < ordered_property_names.index(intent_param)
+
+ for intent_param in intent_params:
+ assert properties[intent_param]["description"] == mcp_browser.AI_FALLBACK_DESCRIPTION
+
+
+async def test_run_task_schema_description_demotes_autonomous_trial() -> None:
+ tools_by_name = {tool.name: tool for tool in await mcp.list_tools()}
+ description = tools_by_name["skyvern_run_task"].description or ""
+
+ assert "one-off autonomous trial" in description
+ assert "highest-cost AI path" in description
+ assert "Not for production or reusable automations" in description
+ assert "Prefer direct tools" in description
+ assert "selector/ref" in description
+ assert "skyvern_observe + skyvern_execute" in description
+
+
def _click_page(monkeypatch: pytest.MonkeyPatch) -> AsyncMock:
click = AsyncMock(return_value="#resolved")
page = SimpleNamespace(click=click)