Skip to content

Commit 5b03e9a

Browse files
committed
fix gaia agent
1 parent 4264168 commit 5b03e9a

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

scripts/run_gaia.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
)
1313

1414
if __name__ == "__main__":
15-
agent_args = TapeAgentArgs("gaia_agent")
1615
study = make_study(
1716
benchmark=GaiaBenchmark(split="validation"),
18-
agent_args=[agent_args],
17+
agent_args=TapeAgentArgs("gaia_agent"),
1918
comment="Gaia eval",
19+
logging_level=logging.DEBUG,
20+
logging_level_stdout=logging.DEBUG,
2021
)
2122
print(f"Exp args list len: {len(study.exp_args_list)}")
2223
study.exp_args_list = study.exp_args_list[:1]

src/agentlab/agents/tapeagent/agent.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from agentlab.agents.agent_args import AgentArgs
1111

1212
logger = logging.getLogger(__name__)
13+
logger.setLevel(logging.INFO)
1314

1415

1516
@dataclass
@@ -49,15 +50,23 @@ def get_action(self, obs: Observation | list[Observation]) -> tuple[str, TapeAge
4950
self.tape = self.tape.append(observation)
5051
thoughts = []
5152
action = None
52-
for event in self.agent.run(self.tape):
53-
if not event.step:
54-
continue
55-
self.tape = self.tape.append(event.step)
56-
if isinstance(event.step, Thought):
57-
thoughts.append(event.step.llm_dict())
58-
logger.info(f"Thought: {event.step.llm_view()}")
59-
elif isinstance(event.step, Action):
60-
action = event.step
61-
logger.info(f"Action: {action}")
62-
break # we stop at the first action
53+
while not action:
54+
for event in self.agent.run(self.tape):
55+
if event.final_tape:
56+
logger.info(
57+
f"agent run final tape state: {[type(s).__name__ for s in self.tape]}"
58+
)
59+
if not event.step:
60+
continue
61+
self.tape = self.tape.append(event.step)
62+
if isinstance(event.step, Thought):
63+
thoughts.append(event.step.llm_dict())
64+
logger.info(f"Thought: {event.step.llm_view()}")
65+
elif isinstance(event.step, Action) and not action:
66+
action = event.step
67+
logger.info(f"Action: {action}")
68+
# we stop at the first action
69+
else:
70+
logger.info(f"Other step: {type(event.step)}")
71+
logger.info(f"Tape state: {[type(s).__name__ for s in self.tape]}")
6372
return (action, TapeAgentInfo(thoughts=thoughts))

0 commit comments

Comments
 (0)