Skip to content

Commit dc231d0

Browse files
committed
update to multi-turn conversation, fix behavior when task can definitely not be completed
1 parent 72991cd commit dc231d0

File tree

3 files changed

+22
-31
lines changed

3 files changed

+22
-31
lines changed

alias/src/alias/agent/agents/_browser_agent.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
from alias.agent.agents.common_agent_utils import (
3737
WorkerResponse,
3838
get_user_input_to_mem_pre_reply_hook,
39+
agent_load_states_pre_reply_hook,
40+
save_post_reasoning_state,
41+
save_post_action_state,
3942
)
4043
from alias.agent.agents._build_in_helper_browser._image_understanding import (
4144
image_understanding,
@@ -281,6 +284,11 @@ def __init__(
281284
# Register hooks (kwargs-only signature)
282285
# compatible with directly using session service,
283286
# add input msg to memory
287+
self.register_instance_hook(
288+
"pre_reply",
289+
"agent_load_states_pre_reply_hook",
290+
agent_load_states_pre_reply_hook,
291+
)
284292
self.register_instance_hook(
285293
"pre_reply",
286294
"get_user_input_to_mem_pre_reply_hook",
@@ -291,11 +299,21 @@ def __init__(
291299
"browser_pre_reply_hook",
292300
browser_pre_reply_hook,
293301
)
302+
self.register_instance_hook(
303+
"post_reasoning",
304+
"save_post_reasoning_state",
305+
save_post_reasoning_state,
306+
)
294307
self.register_instance_hook(
295308
"post_acting",
296309
"browser_post_acting_hook",
297310
browser_post_acting_hook,
298311
)
312+
self.register_instance_hook(
313+
"post_acting",
314+
"save_post_action_state",
315+
save_post_action_state,
316+
)
299317

300318
def _register_skill_tool(
301319
self,
@@ -1373,7 +1391,9 @@ async def _validate_finish_status(self, summary: str) -> str:
13731391
sys_prompt = (
13741392
"You are an expert in task validation. "
13751393
"Your job is to determine if the agent has completed its task"
1376-
" based on the provided summary. If the summary is `NO_ANSWER`, this task is not over. If finished, strictly reply "
1394+
" based on the provided summary. If the summary is `NO_ANSWER`, this task "
1395+
"is not over unless the task is determined as definitely not completed. "
1396+
"If finished, strictly reply "
13771397
'"BROWSER_AGENT_TASK_FINISHED" and your reason, otherwise return the remaining '
13781398
"tasks or next steps."
13791399
)

alias/src/alias/agent/agents/_build_in_prompt_browser/browser_agent_evaluate.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

alias/src/alias/agent/agents/_build_in_prompt_browser/browser_agent_sys_prompt.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Your goal is to complete given tasks by controlling a browser to navigate web pa
2828
- Avoid using Google Scholar. If a researcher is searched, try to use his/her homepage instead.
2929
- When calling `browser_type` function, set the `slow` parameter to `True` to enable slow typing simulation.
3030
- When the answer to the task is found, call `browser_generate_final_response` to finish the process.
31+
- If the task can definitely not be completed, call `browser_generate_final_response` to finish the process and explain why.
3132
### Observing Guidelines
3233
- Always take action based on the elements on the webpage. Never create urls or generate new pages.
3334
- If the webpage is blank or error such as 404 is found, try refreshing it or go back to the previous page and find another webpage.

0 commit comments

Comments
 (0)