make wait_for_completion=False by default for run_task function in the python lib (#2500)

This commit is contained in:
Shuchang Zheng
2025-05-28 15:27:50 -07:00
committed by GitHub
parent fc028212be
commit a2ff8791d6
4 changed files with 107 additions and 30 deletions

View File

@@ -12,6 +12,8 @@ from mcp.server.fastmcp import FastMCP
from rich.panel import Panel
from rich.prompt import Confirm
from skyvern.config import settings
from skyvern.library.skyvern import Skyvern
from skyvern.utils import detect_os
from .console import console
@@ -21,6 +23,36 @@ run_app = typer.Typer(help="Commands to run Skyvern services such as the API ser
mcp = FastMCP("Skyvern")
@mcp.tool()
async def skyvern_run_task(prompt: str, url: str) -> dict[str, str]:
"""Use Skyvern to execute anything in the browser. Useful for accomplishing tasks that require browser automation.
This tool uses Skyvern's browser automation to navigate websites and perform actions to achieve
the user's intended outcome. It can handle tasks like form filling, clicking buttons, data extraction,
and multi-step workflows.
It can even help you find updated data on the internet if your model information is outdated.
Args:
prompt: A natural language description of what needs to be accomplished (e.g. "Book a flight from
NYC to LA", "Sign up for the newsletter", "Find the price of item X", "Apply to a job")
url: The starting URL of the website where the task should be performed
"""
skyvern_agent = Skyvern(
base_url=settings.SKYVERN_BASE_URL,
api_key=settings.SKYVERN_API_KEY,
)
res = await skyvern_agent.run_task(prompt=prompt, url=url, user_agent="skyvern-mcp", wait_for_completion=True)
# TODO: It would be nice if we could return the task URL here
output = res.model_dump()["output"]
base_url = settings.SKYVERN_BASE_URL
run_history_url = (
"https://app.skyvern.com/history" if "skyvern.com" in base_url else "http://localhost:8080/history"
)
return {"output": output, "run_history_url": run_history_url}
def get_pids_on_port(port: int) -> List[int]:
"""Return a list of PIDs listening on the given port."""
pids = []

View File

@@ -303,7 +303,7 @@ class Skyvern(AsyncSkyvern):
data_extraction_schema: dict[str, Any] | str | None = None,
proxy_location: ProxyLocation | None = None,
max_steps: int | None = None,
wait_for_completion: bool = True,
wait_for_completion: bool = False,
timeout: float = DEFAULT_AGENT_TIMEOUT,
browser_session_id: str | None = None,
user_agent: str | None = None,