Skip to content

Commit 45160cd

Browse files
committed
fix cutting message bug
1 parent 21c8f59 commit 45160cd

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

.env.example

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ CHROME_PATH=
2222
CHROME_USER_DATA=
2323
CHROME_DEBUGGING_PORT=9222
2424
CHROME_DEBUGGING_HOST=localhost
25-
CHROME_PERSISTENT_SESSION=false # Set to true to keep browser open between AI tasks
25+
# Set to true to keep browser open between AI tasks
26+
CHROME_PERSISTENT_SESSION=false
2627

2728
# Display settings
28-
RESOLUTION=1920x1080x24 # Format: WIDTHxHEIGHTxDEPTH
29-
RESOLUTION_WIDTH=1920 # Width in pixels
30-
RESOLUTION_HEIGHT=1080 # Height in pixels
29+
# Format: WIDTHxHEIGHTxDEPTH
30+
RESOLUTION=1920x1080x24
31+
# Width in pixels
32+
RESOLUTION_WIDTH=1920
33+
# Height in pixels
34+
RESOLUTION_HEIGHT=1080
3135

3236
# VNC settings
3337
VNC_PASSWORD=youvncpassword

src/agent/custom_agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def __init__(
8989
max_actions_per_step=max_actions_per_step,
9090
tool_call_in_content=tool_call_in_content,
9191
)
92-
if self.llm.model_name in ["deepseek-reasoner"]:
92+
if hasattr(self.llm, 'model_name') and self.llm.model_name in ["deepseek-reasoner"]:
93+
# deepseek-reasoner does not support function calling
9394
self.use_function_calling = False
9495
# TODO: deepseek-reasoner only support 64000 context
9596
self.max_input_tokens = 64000
@@ -242,6 +243,7 @@ async def step(self, step_info: Optional[CustomAgentStepInfo] = None) -> None:
242243
model_output.action, self.browser_context
243244
)
244245
if len(result) != len(model_output.action):
246+
# I think something changes, such information should let LLM know
245247
for ri in range(len(result), len(model_output.action)):
246248
result.append(ActionResult(extracted_content=None,
247249
include_in_memory=True,

src/agent/custom_massage_manager.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ def __init__(
8888
def cut_messages(self):
8989
"""Get current message list, potentially trimmed to max tokens"""
9090
diff = self.history.total_tokens - self.max_input_tokens
91-
i = 1 # start from 1 to keep system message in history
92-
while diff > 0 and i < len(self.history.messages):
93-
self.history.remove_message(i)
91+
while diff > 0 and len(self.history.messages) > 1:
92+
self.history.remove_message(1) # alway remove the oldest one
9493
diff = self.history.total_tokens - self.max_input_tokens
95-
i += 1
9694

9795
def add_state_message(
9896
self,

src/utils/default_config_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def default_config():
1717
"llm_temperature": 1.0,
1818
"llm_base_url": "",
1919
"llm_api_key": "",
20-
"use_own_browser": os.getenv("CHROME_PERSISTENT_SESSION", False),
20+
"use_own_browser": os.getenv("CHROME_PERSISTENT_SESSION", "false").lower() == "true",
2121
"keep_browser_open": False,
2222
"headless": False,
2323
"disable_security": True,

webui.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
from src.utils.default_config_settings import default_config, load_config_from_file, save_config_to_file, save_current_config, update_ui_from_config
3535
from src.utils.utils import update_model_dropdown, get_latest_files, capture_screenshot
3636

37-
from dotenv import load_dotenv
38-
load_dotenv()
3937

4038
# Global variables for persistence
4139
_global_browser = None

0 commit comments

Comments
 (0)