diff --git a/src/agentlab/agents/generic_agent_hinter/__init__.py b/src/agentlab/agents/generic_agent_hinter/__init__.py index 08b44255..4ad73676 100644 --- a/src/agentlab/agents/generic_agent_hinter/__init__.py +++ b/src/agentlab/agents/generic_agent_hinter/__init__.py @@ -1,54 +1,19 @@ -""" -Baseline agent for all ServiceNow papers +import importlib, sys, warnings -This module contains the GenericAgent class, which is the baseline agent for all ServiceNow papers. \ -It is a simple agent that can be ran OOB on all BrowserGym environments. It is also shipped with \ -a few configurations that can be used to run it on different environments. -""" +OLD = __name__ +NEW = "agentlab.agents.hint_use_agent" +SUBS = ("agent_configs", "generic_agent_prompt", "generic_agent", "tmlr_config") -from .agent_configs import ( - AGENT_3_5, - AGENT_8B, - AGENT_37_SONNET, - AGENT_CLAUDE_SONNET_35, - AGENT_CLAUDE_SONNET_35_VISION, - AGENT_CUSTOM, - AGENT_GPT5_MINI, - AGENT_GPT5_NANO, - AGENT_LLAMA3_70B, - AGENT_LLAMA4_17B_INSTRUCT, - AGENT_LLAMA31_70B, - CHAT_MODEL_ARGS_DICT, - RANDOM_SEARCH_AGENT, - AGENT_4o, - AGENT_4o_MINI, - AGENT_4o_MINI_VISION, - AGENT_4o_VISION, - AGENT_o1_MINI, - AGENT_o3_MINI, - FLAGS_GPT_4o, - GenericAgentArgs, +warnings.warn( + f"{OLD} is renamed to {NEW}. {OLD} will be removed in future", + DeprecationWarning, + stacklevel=2, ) -from .generic_agent import GenericAgent, GenericAgentArgs -__all__ = [ - "AGENT_3_5", - "AGENT_4o", - "AGENT_4o_MINI", - "AGENT_4o_VISION", - "AGENT_o3_MINI", - "AGENT_o1_MINI", - "AGENT_LLAMA4_17B_INSTRUCT", - "AGENT_LLAMA3_70B", - "AGENT_LLAMA31_70B", - "AGENT_8B", - "RANDOM_SEARCH_AGENT", - "AGENT_CUSTOM", - "AGENT_CLAUDE_SONNET_35", - "AGENT_37_SONNET", - "AGENT_4o_VISION", - "AGENT_4o_MINI_VISION", - "AGENT_CLAUDE_SONNET_35_VISION", - "AGENT_GPT5_MINI", - "AGENT_GPT5_NANO", -] +# Alias the top-level +new_mod = importlib.import_module(NEW) +sys.modules[OLD] = new_mod + +# Alias known submodules +for sub in SUBS: + sys.modules[f"{OLD}.{sub}"] = importlib.import_module(f"{NEW}.{sub}") diff --git a/src/agentlab/agents/hint_use_agent/__init__.py b/src/agentlab/agents/hint_use_agent/__init__.py new file mode 100644 index 00000000..08b44255 --- /dev/null +++ b/src/agentlab/agents/hint_use_agent/__init__.py @@ -0,0 +1,54 @@ +""" +Baseline agent for all ServiceNow papers + +This module contains the GenericAgent class, which is the baseline agent for all ServiceNow papers. \ +It is a simple agent that can be ran OOB on all BrowserGym environments. It is also shipped with \ +a few configurations that can be used to run it on different environments. +""" + +from .agent_configs import ( + AGENT_3_5, + AGENT_8B, + AGENT_37_SONNET, + AGENT_CLAUDE_SONNET_35, + AGENT_CLAUDE_SONNET_35_VISION, + AGENT_CUSTOM, + AGENT_GPT5_MINI, + AGENT_GPT5_NANO, + AGENT_LLAMA3_70B, + AGENT_LLAMA4_17B_INSTRUCT, + AGENT_LLAMA31_70B, + CHAT_MODEL_ARGS_DICT, + RANDOM_SEARCH_AGENT, + AGENT_4o, + AGENT_4o_MINI, + AGENT_4o_MINI_VISION, + AGENT_4o_VISION, + AGENT_o1_MINI, + AGENT_o3_MINI, + FLAGS_GPT_4o, + GenericAgentArgs, +) +from .generic_agent import GenericAgent, GenericAgentArgs + +__all__ = [ + "AGENT_3_5", + "AGENT_4o", + "AGENT_4o_MINI", + "AGENT_4o_VISION", + "AGENT_o3_MINI", + "AGENT_o1_MINI", + "AGENT_LLAMA4_17B_INSTRUCT", + "AGENT_LLAMA3_70B", + "AGENT_LLAMA31_70B", + "AGENT_8B", + "RANDOM_SEARCH_AGENT", + "AGENT_CUSTOM", + "AGENT_CLAUDE_SONNET_35", + "AGENT_37_SONNET", + "AGENT_4o_VISION", + "AGENT_4o_MINI_VISION", + "AGENT_CLAUDE_SONNET_35_VISION", + "AGENT_GPT5_MINI", + "AGENT_GPT5_NANO", +] diff --git a/src/agentlab/agents/generic_agent_hinter/agent_configs.py b/src/agentlab/agents/hint_use_agent/agent_configs.py similarity index 100% rename from src/agentlab/agents/generic_agent_hinter/agent_configs.py rename to src/agentlab/agents/hint_use_agent/agent_configs.py diff --git a/src/agentlab/agents/generic_agent_hinter/generic_agent.py b/src/agentlab/agents/hint_use_agent/generic_agent.py similarity index 97% rename from src/agentlab/agents/generic_agent_hinter/generic_agent.py rename to src/agentlab/agents/hint_use_agent/generic_agent.py index 843879f8..afc688ed 100644 --- a/src/agentlab/agents/generic_agent_hinter/generic_agent.py +++ b/src/agentlab/agents/hint_use_agent/generic_agent.py @@ -39,6 +39,7 @@ class GenericAgentArgs(AgentArgs): def __post_init__(self): try: # some attributes might be temporarily args.CrossProd for hyperparameter generation + # TODO: Rename the agent to HintUseAgent when appropriate self.agent_name = f"GenericAgent-hinter-{self.chat_model_args.model_name}".replace( "/", "_" ) @@ -92,7 +93,8 @@ def __init__( self.max_retry = max_retry self.flags = flags - if self.flags.hint_db_path is not None: + + if self.flags.hint_db_path is not None and self.flags.use_task_hint: assert os.path.exists( self.flags.hint_db_path ), f"Hint database path {self.flags.hint_db_path} does not exist." @@ -323,7 +325,8 @@ def _get_task_hints(self) -> list[str]: if self.flags.hint_type == "docs": if not hasattr(self, "hint_index"): print("Initializing hint index new time") - self._init() + # @patricebechard It seems _.init() method is missing do we still need it? + # self._init() if self.flags.hint_query_type == "goal": query = self.obs_history[-1]["goal_object"][0]["text"] elif self.flags.hint_query_type == "llm": @@ -331,6 +334,7 @@ def _get_task_hints(self) -> list[str]: # HACK: only 1 query supported query = queries[0] else: + # @patricebechard: This raises an error with the default value 'direct' raise ValueError(f"Unknown hint query type: {self.flags.hint_query_type}") print(f"Query: {query}") @@ -369,7 +373,7 @@ def _get_task_hints(self) -> list[str]: goal_or_queries = "\n".join(self.queries) task_hints = self.hints_source.choose_hints( - self.llm, + self.chat_llm, self.task_name, goal_or_queries, ) diff --git a/src/agentlab/agents/generic_agent_hinter/generic_agent_prompt.py b/src/agentlab/agents/hint_use_agent/generic_agent_prompt.py similarity index 100% rename from src/agentlab/agents/generic_agent_hinter/generic_agent_prompt.py rename to src/agentlab/agents/hint_use_agent/generic_agent_prompt.py diff --git a/src/agentlab/agents/generic_agent_hinter/tmlr_config.py b/src/agentlab/agents/hint_use_agent/tmlr_config.py similarity index 100% rename from src/agentlab/agents/generic_agent_hinter/tmlr_config.py rename to src/agentlab/agents/hint_use_agent/tmlr_config.py