TaskV2: Ask AI if relocation is needed based on current url as the first step (#3761)

This commit is contained in:
Stanislav Novosad
2025-10-22 13:58:40 -06:00
committed by GitHub
parent 66634d3aa6
commit e8472df6d1
3 changed files with 206 additions and 79 deletions

View File

@@ -0,0 +1,27 @@
You're to assist the user to achieve the user goal in the browser. Given the user input and the current url of the browser, what is the url to type into the browser? Also come up with a proper title for this goal to achieve.
MAKE SURE YOU OUTPUT VALID JSON. No text before or after JSON, no trailing commas, no comments (//), no unnecessary quotes, etc.
Reply in JSON format with the following keys:
{
"thoughts": str, // Think step by step. What is the current browser url? Does it already achieve the user goal? Has the user specify a url to go? If yes, what is the complete url user specified? If not, to achieve what the user wants to do, what is most likely website url for achieving the goal?
"url": str, // The initial url to type into the browser. If the user specified one, use exactly that url. If the "current browser url" achieves the user goal, use exactly the "current browser url".
"title": str // A descriptive and informative title for the goal. Use no more than 5 words
}
User goal:
```
{{ user_goal }}
```{% if user_url %}
Starting url provided by user:
```
{{ user_url }}
```{% endif %}
{% if current_browser_url %}
Current browser url:
```
{{ current_browser_url }}
```
{% endif %}

View File

@@ -3786,6 +3786,31 @@ class AgentDB:
await session.refresh(task_run)
return Run.model_validate(task_run)
async def update_task_run(
self,
organization_id: str,
run_id: str,
title: str | None = None,
url: str | None = None,
url_hash: str | None = None,
) -> None:
async with self.Session() as session:
task_run = (
await session.scalars(
select(TaskRunModel).filter_by(run_id=run_id).filter_by(organization_id=organization_id)
)
).first()
if not task_run:
raise NotFoundError(f"TaskRun {run_id} not found")
if title:
task_run.title = title
if url:
task_run.url = url
if url_hash:
task_run.url_hash = url_hash
await session.commit()
async def create_credential(
self,
organization_id: str,