Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Make Copilot's tool descriptions name only what Copilot can call (SKY-17760) (#8818)
Andrew Neilsonf0efb64f45a6
diff --git a/skyvern/forge/agent_functions.py b/skyvern/forge/agent_functions.pyindex 36cd620b7..8468f9470 100644--- a/skyvern/forge/agent_functions.py+++ b/skyvern/forge/agent_functions.py@@ -2758,14 +2758,6 @@ class AgentFunction:if size > CUSTOMER_STORAGE_UPLOAD_MAX_BYTES:raise UploadFileMaxSizeExceeded(file_size_bytes=size, max_size_bytes=CUSTOMER_STORAGE_UPLOAD_MAX_BYTES)- def get_copilot_security_rules(self) -> str:- """Return security guardrails for the workflow copilot system prompt.-- Override in cloud to inject prompt injection defenses.- OSS returns empty string (no hardening).- """- return ""-def copilot_candidate_network_guard(self,browser_context: BrowserContext,diff --git a/skyvern/forge/prompts/skyvern/workflow-copilot-user.j2 b/skyvern/forge/prompts/skyvern/workflow-copilot-user.j2index 39c538c7b..ef656268e 100644--- a/skyvern/forge/prompts/skyvern/workflow-copilot-user.j2+++ b/skyvern/forge/prompts/skyvern/workflow-copilot-user.j2@@ -105,10 +105,6 @@ LOADED RESULT EXTRACTION TARGETS:No previous context available.{% endif %}-{% if request_policy_summary is defined and request_policy_summary %}-TURN SAFETY AND REQUEST CONTEXT: {{ request_policy_summary }}-This block contains facts, not permission or a mandatory next action. If `resolved_credentials` are present, use those `credential_id` values.-{% endif %}DEBUGGER RUN INFORMATION:{% if debug_run_info %}diff --git a/skyvern/forge/prompts/skyvern/workflow_knowledge_base.txt b/skyvern/forge/prompts/skyvern/workflow_knowledge_base.txtindex 0d017a008..fac670395 100644--- a/skyvern/forge/prompts/skyvern/workflow_knowledge_base.txt+++ b/skyvern/forge/prompts/skyvern/workflow_knowledge_base.txt@@ -775,7 +775,7 @@ Purpose: The managed captcha solver is a product capability, enabled by defaultHow a run reaches it:- Task-shaped blocks (navigation, login, action) invoke the solver automatically when a challenge is detected.- A code block invokes it only when its code calls the builtin `await solve_captcha(page)`; nothing runs the solver for a code block otherwise. A challenge that stays unsolved, or that the solver has no route for, raises inside the code block and the run's action trace records a `solve_captcha` action with status `failed`.-- A distorted-text image CAPTCHA (characters drawn in an image, typed into a field) is read by the image form, `await solve_captcha(page, image=<selector>, input=<selector>)`. In Workflow Copilot, while scouting, `solve_page_challenge` with `image` and `input`, or the same call inside `run_browser_code`, runs the same OCR, so the selectors are proven on the live page before they are saved. `image` selects the observed <img>, <svg> or <canvas> holding the text and `input` the observed answer field; both come from the inspected page. It reads the text and types it, and does not submit. It requires image OCR enabled for the organization; otherwise it raises. It raises with nothing typed when the image yields no text, and the runtime enforces a per-block call limit, raising on every call past it. So the block runs a short bounded loop: solve; if the call raised, click the observed refresh control and retry; otherwise submit, and if the form is still shown, click the refresh control and retry. With no refresh control, raise instead of retrying; raise after the last try. An answer typed while scouting fits only that one image and never belongs in the saved code.+- A distorted-text image CAPTCHA (characters drawn in an image, typed into a field) is read by the image form, `await solve_captcha(page, image=<selector>, input=<selector>)`. In Workflow Copilot, while scouting, `solve_page_challenge` with `image` and `input` runs the same OCR, so the selectors are proven on the live page before they are saved. `image` selects the observed <img>, <svg> or <canvas> holding the text and `input` the observed answer field; both come from the inspected page. It reads the text and types it, and does not submit. It requires image OCR enabled for the organization; otherwise it raises. It raises with nothing typed when the image yields no text, and the runtime enforces a per-block call limit, raising on every call past it. So the block runs a short bounded loop: solve; if the call raised, click the observed refresh control and retry; otherwise submit, and if the form is still shown, click the refresh control and retry. With no refresh control, raise instead of retrying; raise after the last try. An answer typed while scouting fits only that one image and never belongs in the saved code.Reading the run: the build-test packet's `challenge` record says whether the solver is available for this organization (`solver_available`), whether this run invoked it (`solver_attempted`, absent when unknown), and what happened (`solver_result`: failed, attempted, not_attempted, or unresolved). "not_attempted" on a code block means the code never called the builtin, not that the product declined. "attempted" means the solve step ran and returned without an error, which is not the same as the challenge clearing: when no solver handles the page the call still reports success. "unresolved" means the run's action history was unavailable or cut short, so whether the solver ran is unknown and should not be stated either way. `solver_available` is resolved per page, and is absent when it was only resolved for a different URL.diff --git a/skyvern/forge/sdk/copilot/agent.py b/skyvern/forge/sdk/copilot/agent.pyindex 2b439a292..26eeb6c23 100644--- a/skyvern/forge/sdk/copilot/agent.py+++ b/skyvern/forge/sdk/copilot/agent.py@@ -1559,7 +1559,6 @@ def _build_user_context(global_llm_context: str,debug_run_info_text: str,user_message: str,- request_policy_summary: str = "",user_workflow_change_summary: str = "",runnable_draft_summary: str = "",user_goal_summary: str = "",@@ -1584,7 +1583,6 @@ def _build_user_context(chat_history=escape_code_fences(redact_raw_secrets_for_prompt(chat_history_text)),global_llm_context=escape_code_fences(redact_raw_secrets_for_structured_prompt(global_llm_context)),debug_run_info=escape_code_fences(redact_raw_secrets_for_structured_prompt(debug_run_info_text)),- request_policy_summary=escape_code_fences(redact_raw_secrets_for_prompt(request_policy_summary)),user_message=escape_code_fences(redact_raw_secrets_for_prompt(user_message)),user_workflow_change_summary=escape_code_fences(user_workflow_change_summary or ""),runnable_draft_summary=escape_code_fences(runnable_draft_summary or ""),diff --git a/skyvern/forge/sdk/copilot/tools/__init__.py b/skyvern/forge/sdk/copilot/tools/__init__.pyindex d4f2ebfc9..2fae4d710 100644--- a/skyvern/forge/sdk/copilot/tools/__init__.py+++ b/skyvern/forge/sdk/copilot/tools/__init__.py@@ -573,10 +573,6 @@ async def edit_block_and_run_tool(draft through the normal author-time safety boundary, then runs ``block_labels`` (or just``label`` when omitted).- To promote code you already ran, pass ``executed_source_reference`` from a prior ``run_browser_code``- cell instead of ``expected_code`` and ``replacement_code``: that cell's complete source replaces the- block's code byte-for-byte. Pass exactly one of the two edit routes.-This is one model-invoked edit and one run. It does not choose an edit, create a block, retry, ordecide whether the result achieved the user's goal. Its response is the same sanitized run/debugevidence returned by ``run_blocks_and_collect_debug``; a failed run still leaves the edited draft@@ -616,17 +612,14 @@ async def edit_block_and_run_tool()return json.dumps(sanitize_tool_result_for_llm("edit_block_and_run", result))- if reference_route == anchored_route or (anchored_route and (expected_code is None or replacement_code is None)):- return fail_before_run(- {- "ok": False,- "error": (- "Pass exactly one edit source: executed_source_reference, or both expected_code and "- "replacement_code."- ),- "error_code": "invalid_edit_source",- }- )+ # Worded from what the call passed, so the reference is named only to a caller that sent one.+ edit_source_error = None+ if reference_route and anchored_route:+ edit_source_error = "Pass executed_source_reference without expected_code or replacement_code."+ elif not reference_route and (expected_code is None or replacement_code is None):+ edit_source_error = "Pass both expected_code and replacement_code."+ if edit_source_error:+ return fail_before_run({"ok": False, "error": edit_source_error, "error_code": "invalid_edit_source"})if label not in requested_labels:return fail_before_run({@@ -1538,9 +1531,6 @@ async def update_and_run_blocks_tool("""Update the workflow and immediately run the specified blocks in one step.Pass the complete workflow as a `workflow` object with the same keys as the workflow YAML, as inupdate_workflow; string values, including multiline code, are plain JSON strings.- To save code you already ran with ``run_browser_code`` as a new block, map the block's label to that- cell's ``executed_source_reference`` in ``executed_source_references`` and leave the block's ``code``- empty: the cell's exact source becomes the block's code, so what gets tested is what you ran.This persists the workflow and remotely executes the selected frontier, waiting for it tofinish, so it is materially higher latency than a bounded page read. It is the surface fortesting durable behaviour, and for reaching a state that only execution can establish --@@ -1997,7 +1987,7 @@ async def inspect_page_for_composition_tool(`evaluate` call to read only that select; do not repeat the full-page inspection.If a block run changes pages, inspect the reached page before authoring downstreamform/search/result blocks. If the evidence shows required fields or controls that- the user did not supply enough information for, ASK_QUESTION with that observed missing input. If+ the user did not supply enough information for, ask the user for that observed missing input. Ifevidence is sufficient, compose and run workflow blocks from the observed fields.`challenge_state` reports what the page looks like, which is not what a run will do:it does not establish that a submit/search path is closed, and a run settles that.@@ -2103,7 +2093,7 @@ async def fill_credential_field_tool("""Fill ONE field of a SAVED credential into a live browser during code-only scouting.`target="debug"` (the default) fills the browser this chat drives; `target="last_run"` fills the- browser the most recent test run executed in, the same one `run_browser_code(target="last_run")` acts on.+ browser the most recent test run executed in.The secret value is resolved server-side from the stored credential and neverenters the conversation; the result reports only `typed_length`. Use this@@ -2380,6 +2370,38 @@ def _with_action_reason(tool: FunctionTool) -> FunctionTool:return dataclasses.replace(tool, params_json_schema=schema, strict_json_schema=False, on_invoke_tool=invoke)+# Each parameter takes a reference only the browser-code tool produces, so a surface without that tool+# advertises neither the parameter nor its text.+_EXECUTED_SOURCE_PARAMS = {+ "edit_block_and_run": (+ "executed_source_reference",+ (+ f"The `executed_source_reference` of a `{BROWSER_CODE_TOOL_NAME}` cell you already ran. That cell's "+ "complete source replaces the block's code byte-for-byte. Pass this instead of `expected_code` and "+ "`replacement_code`."+ ),+ ),+ "update_and_run_blocks": (+ "executed_source_references",+ (+ f"Saves code you already ran with `{BROWSER_CODE_TOOL_NAME}` as a new block: maps the block's label to "+ "that cell's `executed_source_reference`. Leave the block's `code` empty; the cell's exact source "+ "becomes the block's code, so what gets tested is what you ran."+ ),+ ),+}+++def _with_executed_source_param(tool: FunctionTool, *, browser_code_available: bool) -> FunctionTool:+ name, description = _EXECUTED_SOURCE_PARAMS[tool.name]+ schema = copy.deepcopy(tool.params_json_schema)+ if browser_code_available:+ schema["properties"][name]["description"] = description+ else:+ del schema["properties"][name]+ return dataclasses.replace(tool, params_json_schema=schema)++def copilot_native_tools(*,supports_question_tool: bool,@@ -2399,6 +2421,8 @@ def copilot_native_tools(or (tool.name == ACCOUNT_GROUP_SUBMIT_TOOL_NAME and not account_group_submit_enabled())):continue+ if tool.name in _EXECUTED_SOURCE_PARAMS:+ tool = _with_executed_source_param(tool, browser_code_available=browser_code_available)if tool.name in AUTHORING_GUIDANCE_TOOL_NAMES:tool = dataclasses.replace(tool, description=f"{tool.description}\n\n{appended}")elif tool.name in _PAGE_STATE_TOOL_NAMES:diff --git a/skyvern/forge/sdk/copilot/tools/composition_capture.py b/skyvern/forge/sdk/copilot/tools/composition_capture.pyindex d716f8363..d81e61eec 100644--- a/skyvern/forge/sdk/copilot/tools/composition_capture.py+++ b/skyvern/forge/sdk/copilot/tools/composition_capture.py@@ -1555,7 +1555,7 @@ ground concise block prompts. If a select reports `options_omitted=true`, `optioobserved total and its selector remains available. If those options are needed, read that one selectfrom browser code; do not repeat the full-page inspection. If a block run changes pages, inspect thereached page before authoring downstream form/search/result blocks. If the evidence shows required-fields or controls that the user did not supply enough information for, ASK_QUESTION with that+fields or controls that the user did not supply enough information for, ask the user for thatobserved missing input. If evidence is sufficient, compose and run workflow blocks from the observedfields. `challenge_state` reports what the page looks like, which is not what a run will do: it doesnot establish that a submit/search path is closed, and a run settles that.diff --git a/skyvern/forge/sdk/copilot/tools/mcp_hooks.py b/skyvern/forge/sdk/copilot/tools/mcp_hooks.pyindex efc4b1b44..45ce218d5 100644--- a/skyvern/forge/sdk/copilot/tools/mcp_hooks.py+++ b/skyvern/forge/sdk/copilot/tools/mcp_hooks.py@@ -514,6 +514,18 @@ async def _validate_block_pre_hook(}+async def _validate_block_post_hook(+ result: dict[str, Any],+ raw: dict[str, Any],+ ctx: AgentContext,+) -> dict[str, Any]:+ # The server's hint names its own tool and block types this turn may not author.+ error = raw.get("error")+ if isinstance(error, dict) and isinstance(error.get("message"), str):+ result["error"] = error["message"]+ return result++PUBLISH_FILE_HELPER_CONTRACT: dict[str, Any] = {"call": "await publish_file(filename, text=|data=|sheets=|report=|folder=, sources=None)","shadowed_by_parameter": "publish_file",@@ -548,8 +560,8 @@ PUBLISH_FILE_HELPER_CONTRACT: dict[str, Any] = {"run that published it. A block that fails afterwards removes the files it published."),"usage": (- "Pass exactly one content argument per call. Call it inside a code block and prove it with a test run; "- "run_browser_code refuses it. A failed publish raises with the reason. Never write files or paths."+ "Pass exactly one content argument per call. Call it inside a code block and prove it with a test run. "+ "A failed publish raises with the reason. Never write files or paths."),}@@ -639,6 +651,8 @@ async def _get_block_schema_post_hook(_apply_for_loop_schema_guidance(data)block_types = data.get("block_types")if isinstance(block_types, dict):+ # The server's hint names its own tool and a block type this turn may not author.+ data.pop("hint", None)for banned in _copilot_banned_block_types(ctx):block_types.pop(banned, None)if capability.agent_blocks:@@ -2418,11 +2432,21 @@ def _build_skyvern_mcp_overlays(post_hook=_get_workflow_knowledge_post_hook,),"get_block_schema": SchemaOverlay(+ description=(+ "Get the schema for a workflow block type, or list the available types when block_type is omitted."+ ),description_suffix=_block_schema_banned_types_note(capability),pre_hook=_get_block_schema_pre_hook,post_hook=_get_block_schema_post_hook,),- "validate_block": SchemaOverlay(pre_hook=_validate_block_pre_hook),+ "validate_block": SchemaOverlay(+ description=(+ "Check one workflow block definition, passed as a JSON string in block_json, against its block "+ "type's schema. It does not run the block. Returns field-level errors."+ ),+ pre_hook=_validate_block_pre_hook,+ post_hook=_validate_block_post_hook,+ ),"list_org_workflows": SchemaOverlay(description=("Search this organization's saved workflows by title, folder, or parameter name. Reach for it "@@ -2522,7 +2546,9 @@ def _build_skyvern_mcp_overlays("chat. Ask the user to store the value as a saved credential and ""reply with its name; do not type or submit the raw value."),- hide_params=frozenset({"session_id", "cdp_url", "delay", "intent"}),+ # input_method is the Chrome-extension fill; its description names clear, intent and delay,+ # none of which this surface exposes under those names.+ hide_params=frozenset({"session_id", "cdp_url", "delay", "intent", "input_method"}),forced_args={"selector_mode": "direct"},required_overrides=["text"],arg_transforms={"clear_first": "clear"},@@ -2595,6 +2621,7 @@ def _build_skyvern_mcp_overlays(post_hook=_wait_for_either_state_post_hook,),"skyvern_frame_list": SchemaOverlay(+ description="List all frames (including iframes) on the current page.",hide_params=frozenset({"session_id", "cdp_url"}),copilot_params={BROWSER_TARGET_PARAM_NAME: BROWSER_TARGET_PARAM},requires_browser=True,diff --git a/skyvern/forge/sdk/routes/scripts.py b/skyvern/forge/sdk/routes/scripts.pyindex f26860969..f97da2a81 100644--- a/skyvern/forge/sdk/routes/scripts.py+++ b/skyvern/forge/sdk/routes/scripts.py@@ -10,6 +10,7 @@ if TYPE_CHECKING:from skyvern.forge import appfrom skyvern.forge.agent_functions import record_request_audit_event+from skyvern.forge.sdk.artifact.models import Artifactfrom skyvern.forge.sdk.executor.factory import AsyncExecutorFactoryfrom skyvern.forge.sdk.routes.routers import base_routerfrom skyvern.forge.sdk.schemas.organizations import Organization@@ -50,31 +51,25 @@ from skyvern.services.workflow_script_service import (LOG = structlog.get_logger()+SCRIPT_FILE_FETCH_CONCURRENCY = 8+_MAIN_SCRIPT_PATH = "main.py"-async def _load_main_script_content(- organization_id: str,- script_revision_id: str,-) -> str | None:- """Load the main.py content from a script revision, if it exists."""- script_files = await app.DATABASE.scripts.get_script_files(- script_revision_id=script_revision_id,- organization_id=organization_id,- )- for f in script_files:- if f.file_path == "main.py" and f.artifact_id:- artifact = await app.DATABASE.artifacts.get_artifact_by_id(f.artifact_id, organization_id)- if artifact:- data = await app.STORAGE.retrieve_artifact(artifact)- if data:- try:- return data.decode("utf-8") if isinstance(data, bytes) else data- except UnicodeDecodeError:- LOG.error(- "main.py content is not valid UTF-8",- script_revision_id=script_revision_id,- organization_id=organization_id,- )- return None++async def _retrieve_artifact_contents(artifacts: list[Artifact]) -> dict[str, bytes | None]:+ # Per call on purpose: a shared semaphore would queue every request's downloads on the pod behind each other.+ semaphore = asyncio.Semaphore(SCRIPT_FILE_FETCH_CONCURRENCY)++ async def _retrieve(artifact: Artifact) -> bytes | None:+ async with semaphore:+ return await app.STORAGE.retrieve_artifact(artifact)++ try:+ async with asyncio.TaskGroup() as task_group:+ tasks = {artifact.artifact_id: task_group.create_task(_retrieve(artifact)) for artifact in artifacts}+ except ExceptionGroup as group:+ # Re-raise the storage error itself so callers see its type, not the TaskGroup wrapper.+ raise group.exceptions[0]+ return {artifact_id: task.result() for artifact_id, task in tasks.items()}async def get_script_blocks_response(@@ -97,31 +92,54 @@ async def get_script_blocks_response(organization_id=organization_id,script_revision_id=script_revision_id,)- main_script = None- if include_main_script:- main_script = await _load_main_script_content(- organization_id=organization_id,+ if not include_main_script:+ return ScriptBlocksResponse(blocks={}, script_id=script_id, version=version)++ script_files = await app.DATABASE.scripts.get_script_files(+ script_revision_id=script_revision_id,+ organization_id=organization_id,+ )+ # Only this revision's files: a block that points at another revision's file is skipped.+ files_by_id = {script_file.file_id: script_file for script_file in script_files}+ # Reviewer-created blocks have no script_file_id; their code is extracted from main.py.+ needs_main_script = include_main_script or any(not block.script_file_id for block in script_blocks)+ main_script_artifact_id = next(+ (f.artifact_id for f in script_files if needs_main_script and f.file_path == _MAIN_SCRIPT_PATH), None+ )++ artifact_ids: dict[str, None] = {}+ for script_block in script_blocks:+ block_file = files_by_id.get(script_block.script_file_id) if script_block.script_file_id else None+ if block_file and block_file.artifact_id:+ artifact_ids[block_file.artifact_id] = None+ if main_script_artifact_id:+ artifact_ids[main_script_artifact_id] = None++ artifacts = await app.DATABASE.artifacts.get_artifacts_by_ids(list(artifact_ids), organization_id)+ contents = await _retrieve_artifact_contents(artifacts)++ main_script: str | None = None+ main_script_data = contents.get(main_script_artifact_id) if main_script_artifact_id else None+ if main_script_data:+ try:+ main_script = main_script_data.decode("utf-8")+ except UnicodeDecodeError:+ LOG.error(+ "main.py content is not valid UTF-8",script_revision_id=script_revision_id,+ organization_id=organization_id,)- return ScriptBlocksResponse(blocks={}, main_script=main_script, script_id=script_id, version=version)result: dict[str, str] = {}main_py_block_codes: dict[str, str] | None = None- # TODO(jdo): make concurrent to speed upfor script_block in script_blocks:script_file_id = script_block.script_file_idif not script_file_id:- # Reviewer-created blocks have no script_file_id — fall back to- # extracting the block code from main.py (lazy-loaded once).block_label = script_block.script_block_labelif main_py_block_codes is None:- content = await _load_main_script_content(- organization_id=organization_id,- script_revision_id=script_revision_id,- )- main_py_block_codes = extract_cached_blocks_from_source(content) if content else {}+ main_py_block_codes = extract_cached_blocks_from_source(main_script) if main_script else {}if block_label in main_py_block_codes:result[block_label] = main_py_block_codes[block_label]@@ -136,11 +154,7 @@ async def get_script_blocks_response()continue- script_file = await app.DATABASE.scripts.get_script_file_by_id(- script_revision_id=script_revision_id,- file_id=script_file_id,- organization_id=organization_id,- )+ script_file = files_by_id.get(script_file_id)if not script_file:LOG.info(@@ -166,12 +180,7 @@ async def get_script_blocks_response()continue- artifact = await app.DATABASE.artifacts.get_artifact_by_id(- artifact_id,- organization_id,- )-- if not artifact:+ if artifact_id not in contents:LOG.warning("No artifact found for script file",workflow_permanent_id=workflow_permanent_id,@@ -183,7 +192,7 @@ async def get_script_blocks_response()continue- data = await app.STORAGE.retrieve_artifact(artifact)+ data = contents[artifact_id]if not data:LOG.warning(@@ -212,14 +221,12 @@ async def get_script_blocks_response()continue- main_script = None- if include_main_script:- main_script = await _load_main_script_content(- organization_id=organization_id,- script_revision_id=script_revision_id,- )-- return ScriptBlocksResponse(blocks=result, main_script=main_script, script_id=script_id, version=version)+ return ScriptBlocksResponse(+ blocks=result,+ main_script=main_script if include_main_script else None,+ script_id=script_id,+ version=version,+ )@base_router.post(diff --git a/tests/unit/copilot_route_test_support.py b/tests/unit/copilot_route_test_support.pyindex 965ba226f..194f3a254 100644--- a/tests/unit/copilot_route_test_support.py+++ b/tests/unit/copilot_route_test_support.py@@ -166,7 +166,6 @@ def setup_new_copilot_mocks(app.DATABASE.observer = SimpleNamespace(get_workflow_run_blocks=AsyncMock(return_value=[]),)- app.AGENT_FUNCTION.get_copilot_security_rules = MagicMock(return_value="")app.AGENT_FUNCTION.get_copilot_config = MagicMock(return_value=None)app.AGENT_FUNCTION.get_copilot_config_for_request = AsyncMock(return_value=CopilotConfig(block_authoring_policy=BlockAuthoringPolicy.TASK_V3_PURE)diff --git a/tests/unit/forge/sdk/copilot/test_browser_code_tool.py b/tests/unit/forge/sdk/copilot/test_browser_code_tool.pyindex d7a5639b2..5bd2433a2 100644--- a/tests/unit/forge/sdk/copilot/test_browser_code_tool.py+++ b/tests/unit/forge/sdk/copilot/test_browser_code_tool.py@@ -108,6 +108,19 @@ async def test_the_code_tool_mode_decides_whether_it_joins_or_replaces_the_direcassert len({oss.sha256, added.sha256, replaced.sha256}) == 3+def test_executed_source_parameters_are_advertised_only_with_the_tool_that_produces_them() -> None:+ def advertised(browser_code_available: bool) -> dict[str, dict[str, Any]]:+ tools = copilot_native_tools(supports_question_tool=True, browser_code_available=browser_code_available)+ return {tool.name: tool.params_json_schema["properties"] for tool in tools}++ with_code_tool, without_code_tool = advertised(True), advertised(False)++ assert with_code_tool["edit_block_and_run"]["executed_source_reference"]["description"]+ assert with_code_tool["update_and_run_blocks"]["executed_source_references"]["description"]+ assert "executed_source_reference" not in without_code_tool["edit_block_and_run"]+ assert "executed_source_references" not in without_code_tool["update_and_run_blocks"]++class _LeaseProbeSession:"""Records whether the browser lease was still held when each cell ran."""diff --git a/tests/unit/test_workflow_copilot_cancel.py b/tests/unit/test_workflow_copilot_cancel.pyindex 7bfaa46aa..4c41ddb49 100644--- a/tests/unit/test_workflow_copilot_cancel.py+++ b/tests/unit/test_workflow_copilot_cancel.py@@ -1342,7 +1342,6 @@ async def test_operational_cancel_records_the_turn_as_interrupted_and_still_re_rapp.DATABASE.observer = SimpleNamespace(get_workflow_run_blocks=AsyncMock(return_value=[]),)- app.AGENT_FUNCTION.get_copilot_security_rules = MagicMock(return_value="")# Make sure no cache is configured so the watcher never spawns and# user_cancel_observed[0] stays False.diff --git a/tests/unit/test_workflow_copilot_prompt_rewrite.py b/tests/unit/test_workflow_copilot_prompt_rewrite.pyindex f109231cf..27c814b36 100644--- a/tests/unit/test_workflow_copilot_prompt_rewrite.py+++ b/tests/unit/test_workflow_copilot_prompt_rewrite.py@@ -1,5 +1,6 @@from __future__ import annotations+import copyimport jsonfrom collections.abc import Callablefrom functools import lru_cache@@ -8,6 +9,7 @@ from typing import Anyimport pytest+from skyvern.cli.mcp_tools.blocks import skyvern_block_schema, skyvern_block_validatefrom skyvern.forge import appfrom skyvern.forge.agent_functions import AgentFunctionfrom skyvern.forge.sdk.copilot.agent import _build_dynamic_system_prompt, _build_tool_usage_guide@@ -20,6 +22,7 @@ from skyvern.forge.sdk.copilot.config import (from skyvern.forge.sdk.copilot.context import CopilotContextfrom skyvern.forge.sdk.copilot.mcp_adapter import _copilot_to_call_tool_resultfrom skyvern.forge.sdk.copilot.request_policy import RequestPolicy+from skyvern.forge.sdk.copilot.runtime import mcp_to_copilotfrom skyvern.forge.sdk.copilot.tools import NATIVE_TOOLS, _build_skyvern_mcp_overlaysfrom skyvern.forge.sdk.copilot.tools.banned_blocks import (AUTHORING_FAMILY_GUIDANCE,@@ -214,3 +217,28 @@ def test_ask_carve_out_gates_money_and_destruction_and_never_a_site_sent_message# A page click that makes the site email its own account holder is not the workflow# sending anything, and no permission clause may read it as one.assert "message or email" not in prompt+++async def test_block_type_list_drops_the_mcp_servers_hint() -> None:+ listed = await skyvern_block_schema()+ assert "hint" in listed["data"]++ # The server returns its module-level catalog and the hook edits what it is given in place.+ payload = copy.deepcopy(listed["data"])+ rendered = await _get_block_schema_post_hook({"ok": True, "data": payload}, {}, _code_only_ctx())++ assert rendered["data"]["block_types"]+ assert "hint" not in rendered["data"]+++async def test_a_failed_validation_reaches_the_model_without_the_mcp_servers_hint() -> None:+ raw = await skyvern_block_validate(block_json='{"block_type": "code"}')+ assert raw["error"]["hint"]++ post_hook = _build_skyvern_mcp_overlays()["validate_block"].post_hook+ rendered = await post_hook(mcp_to_copilot(raw), raw, _code_only_ctx())++ assert rendered["ok"] is False+ assert rendered["error"] == raw["error"]["message"]diff --git a/tests/unit/test_workflow_copilot_route.py b/tests/unit/test_workflow_copilot_route.pyindex 87638fd03..b1a879b4c 100644--- a/tests/unit/test_workflow_copilot_route.py+++ b/tests/unit/test_workflow_copilot_route.py@@ -2206,7 +2206,6 @@ async def test_flag_on_pre_agent_failure_persists_recoverable_reply(app.DATABASE.observer = SimpleNamespace(get_workflow_run_blocks=AsyncMock(return_value=[]),)- app.AGENT_FUNCTION.get_copilot_security_rules = MagicMock(return_value="")app.AGENT_FUNCTION.get_copilot_config = MagicMock(return_value=None)app.AGENT_FUNCTION.get_copilot_config_for_request = AsyncMock(return_value=None)app.AGENT_FUNCTION.resolve_org_api_key = AsyncMock(return_value="sk-test-key")