Skip to content

Commit cf0e9b3

Browse files
Rename generic agent hinter to hint_use_agent (#311)
* rename generic_agent_hinter to hint_use_agent for clarity * Add deprecation warning and module alias for generic_agent_hinter * improve module aliasing for submodules * Add todo rename agent name * black * bugfix: check for hint_db only when use_task_hint is true. * fix: address missing initialization and correct args reference in choose_hints method * black
1 parent f06c6d0 commit cf0e9b3

File tree

6 files changed

+76
-53
lines changed

6 files changed

+76
-53
lines changed
Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,19 @@
1-
"""
2-
Baseline agent for all ServiceNow papers
1+
import importlib, sys, warnings
32

4-
This module contains the GenericAgent class, which is the baseline agent for all ServiceNow papers. \
5-
It is a simple agent that can be ran OOB on all BrowserGym environments. It is also shipped with \
6-
a few configurations that can be used to run it on different environments.
7-
"""
3+
OLD = __name__
4+
NEW = "agentlab.agents.hint_use_agent"
5+
SUBS = ("agent_configs", "generic_agent_prompt", "generic_agent", "tmlr_config")
86

9-
from .agent_configs import (
10-
AGENT_3_5,
11-
AGENT_8B,
12-
AGENT_37_SONNET,
13-
AGENT_CLAUDE_SONNET_35,
14-
AGENT_CLAUDE_SONNET_35_VISION,
15-
AGENT_CUSTOM,
16-
AGENT_GPT5_MINI,
17-
AGENT_GPT5_NANO,
18-
AGENT_LLAMA3_70B,
19-
AGENT_LLAMA4_17B_INSTRUCT,
20-
AGENT_LLAMA31_70B,
21-
CHAT_MODEL_ARGS_DICT,
22-
RANDOM_SEARCH_AGENT,
23-
AGENT_4o,
24-
AGENT_4o_MINI,
25-
AGENT_4o_MINI_VISION,
26-
AGENT_4o_VISION,
27-
AGENT_o1_MINI,
28-
AGENT_o3_MINI,
29-
FLAGS_GPT_4o,
30-
GenericAgentArgs,
7+
warnings.warn(
8+
f"{OLD} is renamed to {NEW}. {OLD} will be removed in future",
9+
DeprecationWarning,
10+
stacklevel=2,
3111
)
32-
from .generic_agent import GenericAgent, GenericAgentArgs
3312

34-
__all__ = [
35-
"AGENT_3_5",
36-
"AGENT_4o",
37-
"AGENT_4o_MINI",
38-
"AGENT_4o_VISION",
39-
"AGENT_o3_MINI",
40-
"AGENT_o1_MINI",
41-
"AGENT_LLAMA4_17B_INSTRUCT",
42-
"AGENT_LLAMA3_70B",
43-
"AGENT_LLAMA31_70B",
44-
"AGENT_8B",
45-
"RANDOM_SEARCH_AGENT",
46-
"AGENT_CUSTOM",
47-
"AGENT_CLAUDE_SONNET_35",
48-
"AGENT_37_SONNET",
49-
"AGENT_4o_VISION",
50-
"AGENT_4o_MINI_VISION",
51-
"AGENT_CLAUDE_SONNET_35_VISION",
52-
"AGENT_GPT5_MINI",
53-
"AGENT_GPT5_NANO",
54-
]
13+
# Alias the top-level
14+
new_mod = importlib.import_module(NEW)
15+
sys.modules[OLD] = new_mod
16+
17+
# Alias known submodules
18+
for sub in SUBS:
19+
sys.modules[f"{OLD}.{sub}"] = importlib.import_module(f"{NEW}.{sub}")
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"""
2+
Baseline agent for all ServiceNow papers
3+
4+
This module contains the GenericAgent class, which is the baseline agent for all ServiceNow papers. \
5+
It is a simple agent that can be ran OOB on all BrowserGym environments. It is also shipped with \
6+
a few configurations that can be used to run it on different environments.
7+
"""
8+
9+
from .agent_configs import (
10+
AGENT_3_5,
11+
AGENT_8B,
12+
AGENT_37_SONNET,
13+
AGENT_CLAUDE_SONNET_35,
14+
AGENT_CLAUDE_SONNET_35_VISION,
15+
AGENT_CUSTOM,
16+
AGENT_GPT5_MINI,
17+
AGENT_GPT5_NANO,
18+
AGENT_LLAMA3_70B,
19+
AGENT_LLAMA4_17B_INSTRUCT,
20+
AGENT_LLAMA31_70B,
21+
CHAT_MODEL_ARGS_DICT,
22+
RANDOM_SEARCH_AGENT,
23+
AGENT_4o,
24+
AGENT_4o_MINI,
25+
AGENT_4o_MINI_VISION,
26+
AGENT_4o_VISION,
27+
AGENT_o1_MINI,
28+
AGENT_o3_MINI,
29+
FLAGS_GPT_4o,
30+
GenericAgentArgs,
31+
)
32+
from .generic_agent import GenericAgent, GenericAgentArgs
33+
34+
__all__ = [
35+
"AGENT_3_5",
36+
"AGENT_4o",
37+
"AGENT_4o_MINI",
38+
"AGENT_4o_VISION",
39+
"AGENT_o3_MINI",
40+
"AGENT_o1_MINI",
41+
"AGENT_LLAMA4_17B_INSTRUCT",
42+
"AGENT_LLAMA3_70B",
43+
"AGENT_LLAMA31_70B",
44+
"AGENT_8B",
45+
"RANDOM_SEARCH_AGENT",
46+
"AGENT_CUSTOM",
47+
"AGENT_CLAUDE_SONNET_35",
48+
"AGENT_37_SONNET",
49+
"AGENT_4o_VISION",
50+
"AGENT_4o_MINI_VISION",
51+
"AGENT_CLAUDE_SONNET_35_VISION",
52+
"AGENT_GPT5_MINI",
53+
"AGENT_GPT5_NANO",
54+
]

src/agentlab/agents/generic_agent_hinter/generic_agent.py renamed to src/agentlab/agents/hint_use_agent/generic_agent.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class GenericAgentArgs(AgentArgs):
3939

4040
def __post_init__(self):
4141
try: # some attributes might be temporarily args.CrossProd for hyperparameter generation
42+
# TODO: Rename the agent to HintUseAgent when appropriate
4243
self.agent_name = f"GenericAgent-hinter-{self.chat_model_args.model_name}".replace(
4344
"/", "_"
4445
)
@@ -92,7 +93,8 @@ def __init__(
9293
self.max_retry = max_retry
9394

9495
self.flags = flags
95-
if self.flags.hint_db_path is not None:
96+
97+
if self.flags.hint_db_path is not None and self.flags.use_task_hint:
9698
assert os.path.exists(
9799
self.flags.hint_db_path
98100
), f"Hint database path {self.flags.hint_db_path} does not exist."
@@ -323,14 +325,16 @@ def _get_task_hints(self) -> list[str]:
323325
if self.flags.hint_type == "docs":
324326
if not hasattr(self, "hint_index"):
325327
print("Initializing hint index new time")
326-
self._init()
328+
# @patricebechard It seems _.init() method is missing do we still need it?
329+
# self._init()
327330
if self.flags.hint_query_type == "goal":
328331
query = self.obs_history[-1]["goal_object"][0]["text"]
329332
elif self.flags.hint_query_type == "llm":
330333
queries, _ = self._get_queries()
331334
# HACK: only 1 query supported
332335
query = queries[0]
333336
else:
337+
# @patricebechard: This raises an error with the default value 'direct'
334338
raise ValueError(f"Unknown hint query type: {self.flags.hint_query_type}")
335339

336340
print(f"Query: {query}")
@@ -369,7 +373,7 @@ def _get_task_hints(self) -> list[str]:
369373
goal_or_queries = "\n".join(self.queries)
370374

371375
task_hints = self.hints_source.choose_hints(
372-
self.llm,
376+
self.chat_llm,
373377
self.task_name,
374378
goal_or_queries,
375379
)

0 commit comments

Comments
 (0)