Skip to content

Commit 1c0c514

Browse files
fix
1 parent 7a0c4c3 commit 1c0c514

6 files changed

Lines changed: 14 additions & 14 deletions

File tree

lagent/actions/mcp_client.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ def _start_loop(loop):
4242
return event_loop
4343

4444

45-
logger = logging.getLogger(__file__)
46-
47-
4845
class TokenBucket:
4946
def __init__(self, rate_limit: float):
5047
self.rate_limit = rate_limit # tokens per second
@@ -404,7 +401,8 @@ async def run(self, **kwargs) -> ActionReturn:
404401
# 否则直接作为字符串返回
405402
try:
406403
result = self._parser.parse_outputs(outputs)
407-
except:
404+
except Exception as exc:
405+
logger.warning(f"Failed to parse MCP Action {self.name} output: {exc}")
408406
result = str(outputs)
409407

410408
action_return = ActionReturn(fallback_args, type=self.name, result=result)

lagent/actions/web_visitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class WebVisitor(AsyncActionMixin, BaseAction):
7070
2. **Key Extraction for Evidence**: Identify and extract the **most relevant information** from the content, you never miss any important information, output the **full original context** of the content as far as possible, it can be more than three paragraphs.
7171
3. **Summary Output for Summary**: Organize into a concise paragraph with logical flow, prioritizing clarity and judge the contribution of the information to the goal.
7272
73-
**Final Output Format using JSON format has "rational", "evidence", "summary" feilds**
73+
**Final Output Format using JSON format has "rational", "evidence", "summary" fields**
7474
"""
7575

7676
def __init__(

lagent/agents/fc_agent.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ def __init__(
7878
async def forward(self, env_message: AgentMessage, session_id: str | int, **kwargs):
7979
selection_message: AgentMessage = None
8080
current_turn = 0
81-
while (
82-
self.finish_condition is None
83-
or not self.finish_condition(selection_message, env_message)
84-
and (self.max_turn is None or current_turn < self.max_turn)
81+
while (self.finish_condition is None or not self.finish_condition(selection_message, env_message)) and (
82+
self.max_turn is None or current_turn < self.max_turn
8583
):
8684
selection_message = await self.select_agent(env_message, session_id=session_id, **kwargs)
8785
if selection_message.stream_state == AgentStatusCode.SERVER_ERR:
@@ -90,13 +88,15 @@ async def forward(self, env_message: AgentMessage, session_id: str | int, **kwar
9088
for _ in range(2): # remove the last two messages
9189
self.select_agent.memory.get(session_id).delete(-1)
9290
return AgentMessage(
93-
role='env', content='Exceeded context length limit', finish_reason=selection_message.finish_reason
91+
sender=self.name,
92+
content='Exceeded context length limit',
93+
finish_reason=selection_message.finish_reason,
9494
)
9595
if selection_message.finish_reason == 'abort':
96-
return AgentMessage(role='env', content='Aborted request', finish_reason='abort')
96+
return AgentMessage(sender=self.name, content='Aborted request', finish_reason='abort')
9797
env_message = await self.env_agent(selection_message, session_id=session_id)
9898
current_turn += 1
99-
return AgentMessage(role="env", content="Finished", finish_reason='stop')
99+
return AgentMessage(sender=self.name, content="Finished", finish_reason='stop')
100100

101101

102102
class EnvAgent(AsyncAgent):

lagent/memory/base_memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def delete(self, index: Union[List[int], int]) -> None:
3838
for i in sorted(index, reverse=True):
3939
del self.memory[i]
4040

41-
def load(self, memories: Union[str, dict, List], overwrite: bool = True) -> None:
41+
def load(self, memories: Union[dict, List], overwrite: bool = True) -> None:
4242
if overwrite:
4343
self.memory = []
4444
if isinstance(memories, dict):

lagent/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class AgentMessage(BaseModel):
9696
tool_calls: Optional[List[dict]] = None
9797
tool_calls_ids: Optional[List[str]] = None
9898
formatted: Optional[Any] = None
99-
extra_info: dict = {}
99+
extra_info: dict = Field(default_factory=dict)
100100
type: Optional[str] = None
101101
receiver: Optional[str] = None
102102
stream_state: Union[ModelStatusCode, AgentStatusCode] = AgentStatusCode.END

requirements/runtime.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ jsonschema
1212
jupyter==1.0.0
1313
jupyter_client==8.6.2
1414
jupyter_core==5.7.2
15+
openai
1516
pydantic
17+
ray
1618
requests
1719
tenacity
1820
termcolor

0 commit comments

Comments
 (0)