Skip to content

Commit ca1c42c

Browse files
committed
Add method to retrieve last summary and update ToolUseAgent logic for enhanced context
1 parent b18e1e0 commit ca1c42c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/agentlab/agents/tool_use_agent/multi_tool_agent.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ def set_last_summary(self, summary: MessageBuilder):
105105
# append None to summaries until we reach the current group index
106106
self.groups[-1].summary = summary
107107

108+
def get_last_summary(self) -> MessageBuilder | None:
109+
"""Get the last summary message."""
110+
if len(self.groups) == 0:
111+
return None
112+
return self.groups[-1].summary
113+
108114
def is_goal_set(self) -> bool:
109115
"""Check if the goal is set in the first group."""
110116
return len(self.groups) > 0
@@ -460,6 +466,9 @@ def get_action(self, obs: Any) -> float:
460466

461467
action = response.action
462468
think = response.think
469+
last_summary = self.discussion.get_last_summary()
470+
if last_summary is not None:
471+
think = last_summary.content[0]["text"] + "\n" + think
463472

464473
self.discussion.new_group()
465474
self.discussion.append(response.tool_calls)
@@ -517,17 +526,19 @@ def get_action(self, obs: Any) -> float:
517526
obs=Obs(
518527
use_last_error=True,
519528
use_screenshot=True,
520-
use_axtree=False,
521-
use_dom=True,
529+
use_axtree=True,
530+
use_dom=False,
522531
use_som=False,
523532
use_tabs=False,
524533
),
525534
summarizer=Summarizer(do_summary=True),
526535
general_hints=GeneralHints(use_hints=False),
527536
task_hint=TaskHint(use_task_hint=True),
528-
keep_last_n_obs=1, # keep only the last observation in the discussion
537+
keep_last_n_obs=None, # keep only the last observation in the discussion
529538
multiaction=False, # whether to use multi-action or not
530-
action_subsets=("bid",),
539+
# action_subsets=("bid",),
540+
action_subsets=("coord"),
541+
# action_subsets=("coord", "bid"),
531542
)
532543

533544
AGENT_CONFIG = ToolUseAgentArgs(

0 commit comments

Comments
 (0)