Skip to content

Commit 55f2ffa

Browse files
committed
store thoughts in agent info without serialization
1 parent 418764f commit 55f2ffa

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/agentlab/agents/tapeagent/agent.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import bgym
66
import hydra
7-
from pydantic import json
87
from tapeagents.agent import Agent
98
from tapeagents.core import Action, Observation, Tape, Thought
109

@@ -25,6 +24,11 @@ def make_agent(self) -> bgym.Agent:
2524
return TapeAgent(agent=agent, tape=Tape(steps=[]))
2625

2726

27+
@dataclass
28+
class TapeAgentInfo(bgym.AgentInfo):
29+
thoughts: list[Thought] = None
30+
31+
2832
class TapeAgent(bgym.Agent):
2933
agent: Agent
3034
tape: Tape
@@ -34,8 +38,8 @@ def __init__(self, agent: Agent, tape: Tape):
3438
self.agent = agent
3539
self.tape = tape
3640

37-
def obs_preprocessor(self, obs: dict) -> Any:
38-
logger.info(f"Preprocessing observation: {obs}")
41+
def obs_preprocessor(self, obs: Any) -> Any:
42+
logger.info(f"Observation: {obs}")
3943
return obs
4044

4145
def get_action(
@@ -57,4 +61,4 @@ def get_action(
5761
action = event.step.llm_view()
5862
logger.info(f"Action: {action}")
5963
break # we stop at the first action
60-
return (action, bgym.AgentInfo(think=json.dumps(thoughts), stats={}))
64+
return (action, TapeAgentInfo(thoughts=thoughts))

0 commit comments

Comments
 (0)