Fix chrome user data dir problem (#2503)

This commit is contained in:
Shuchang Zheng
2025-05-28 22:41:06 -07:00
committed by GitHub
parent 869757398a
commit cf08ca951e
11 changed files with 283 additions and 85 deletions

View File

@@ -1,9 +1,8 @@
---
title: Task Features
title: Run Tasks
slug: running-tasks/run-tasks
---
## Run A Task
- [Quickstart](/getting-started/quickstart) to run a task.
- [Run Task API](/api-reference/api-reference/agent/run-task)
@@ -13,6 +12,8 @@ Every feature in this page is enabled through API & SDK. Some features are enabl
<img src="../images/run_tasks/ui_run_task.png" alt="Configure advanced settings in the UI" width="400" />
</Frame>
## Parameters
### [Engine](/api-reference/api-reference/agent/run-task#request.body.engine)
Parameter: `engine`
@@ -75,4 +76,101 @@ Parameter: `browser_session_id`
You can set a browser session for a task. Having a browser session persist the real-time state of the browser, so that the next run can continue from where the previous run left off.
See the [Browser Sessions](/browser-sessions/introduction) section to see how to create a browser session.
See the [Browser Sessions](/browser-sessions/introduction) section to see how to create a browser session.
## Use Cases
### Control Your Own Browser (Chrome)
<Warning>Since [Chrome 136](https://developer.chrome.com/blog/remote-debugging-port), Chrome refuses any CDP connect to the browser using the default user_data_dir. In order to use your browser data, Skyvern copies your default user_data_dir to `./tmp/user_data_dir` the first time connecting to your local browser.</Warning>
**Just With Python Code**
```python
from skyvern import Skyvern
# The path to your Chrome browser. This example path is for Mac.
browser_path = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
skyvern = Skyvern(
base_url="http://localhost:8000",
api_key="YOUR_API_KEY",
browser_path=browser_path,
)
task = await skyvern.run_task(
prompt="Find the top post on hackernews today",
)
```
**With Skyvern Service**
```bash
# The path to your Chrome browser. This example path is for Mac.
CHROME_EXECUTABLE_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
BROWSER_TYPE=cdp-connect
```
Restart your Skyvern service `skyvern run server` and run the task through UI or code:
```python
from skyvern import Skyvern
skyvern = Skyvern(
base_url="http://localhost:8000",
api_key="YOUR_API_KEY",
)
task = await skyvern.run_task(
prompt="Find the top post on hackernews today",
)
```
### Get Consistent Output Schema
You can do it by adding the `data_extraction_schema` parameter to your task.
For example, if you want to get the title, URL, and points of the top post on Hacker News today, you can add the following to your task:
```python
from skyvern import Skyvern
skyvern = Skyvern()
task = await skyvern.run_task(
prompt="Find the top post on hackernews today",
data_extraction_schema={
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "The title of the top post"
},
"url": {
"type": "string",
"description": "The URL of the top post"
},
"points": {
"type": "integer",
"description": "Number of points the post has received"
}
}
}
)
```
### Wait Until Task Is Done
When you are sending a run task request the Skyvern service, you can set the `wait_for_completion` to `True` and wait until the task is done.
```python
from skyvern import Skyvern
skyvern = Skyvern()
task = await skyvern.run_task(
prompt="Find the top post on hackernews today",
# the request will be hanging until the task is done
wait_for_completion=True,
)
print(task.output)
```
### Send Run Result To Your Webhook
Instead of waiting, you can also set the `webhook_url` in the run task request and get the result in your webhook whenever it's done.
```python
from skyvern import Skyvern
skyvern = Skyvern()
task = await skyvern.run_task(
prompt="Find the top post on hackernews today",
webhook_url="https://your-webhook-url.com",
)
```
You can also use the [GET RUN API](/api-reference/api-reference/agent/get-run) to get the current status of the task.