add max_observe in toolcall and manus

This commit is contained in:
xiangjinyu 2025-03-12 17:23:08 +08:00
parent c96c016feb
commit 548c402316
2 changed files with 7 additions and 1 deletions

View File

@ -26,6 +26,8 @@ class Manus(ToolCallAgent):
system_prompt: str = SYSTEM_PROMPT
next_step_prompt: str = NEXT_STEP_PROMPT
max_observe: int = 2000
# Add general-purpose tools to the tool collection
available_tools: ToolCollection = Field(
default_factory=lambda: ToolCollection(

View File

@ -1,5 +1,5 @@
import json
from typing import Any, List, Literal
from typing import Any, List, Literal, Optional, Union
from pydantic import Field
@ -31,6 +31,7 @@ class ToolCallAgent(ReActAgent):
tool_calls: List[ToolCall] = Field(default_factory=list)
max_steps: int = 30
max_observe: Optional[Union[int, bool]] = None
async def think(self) -> bool:
"""Process current state and decide next actions using tools"""
@ -114,6 +115,9 @@ class ToolCallAgent(ReActAgent):
f"🎯 Tool '{command.function.name}' completed its mission! Result: {result}"
)
if self.max_observe:
result = result[: self.max_observe]
# Add tool response to memory
tool_msg = Message.tool_message(
content=result, tool_call_id=command.id, name=command.function.name