Skip to content

Commit 74dfaf1

Browse files
committed
feat(cuga): new cuga release
1 parent 91d73e7 commit 74dfaf1

4 files changed

Lines changed: 58 additions & 31 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ dependencies = [
134134
"fastparquet>=2024.11.0,<2025.0.0",
135135
"traceloop-sdk>=0.43.1,<1.0.0",
136136
"vlmrun[all]>=0.2.0",
137-
"cuga==0.1.2",
137+
"cuga==0.1.4",
138138
"agent-lifecycle-toolkit",
139139
"astrapy>=2.1.0,<3.0.0",
140140
]

src/backend/tests/unit/components/agents/test_cuga_agent.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def default_kwargs(self):
7272
"browser_enabled": False,
7373
"web_apps": "",
7474
"API": False,
75+
"lite_mode": True,
76+
"lite_mode_tool_threshold": 25,
7577
}
7678

7779
async def test_build_config_update(self, component_class, default_kwargs):
@@ -389,6 +391,8 @@ async def test_new_input_fields_present(self, component_class, default_kwargs):
389391
assert "browser_enabled" in input_names
390392
assert "web_apps" in input_names
391393
assert "API" in input_names
394+
assert "lite_mode" in input_names
395+
assert "lite_mode_tool_threshold" in input_names
392396

393397
# Verify default values
394398
assert hasattr(component, "policies")
@@ -398,9 +402,13 @@ async def test_new_input_fields_present(self, component_class, default_kwargs):
398402
assert hasattr(component, "browser_enabled")
399403
assert hasattr(component, "web_apps")
400404
assert hasattr(component, "API")
405+
assert hasattr(component, "lite_mode")
406+
assert hasattr(component, "lite_mode_tool_threshold")
401407
assert component.n_messages == 100
402408
assert component.browser_enabled is False
403409
assert component.API is False
410+
assert component.lite_mode is True
411+
assert component.lite_mode_tool_threshold == 25
404412

405413
async def test_cuga_has_correct_outputs(self, component_class, default_kwargs):
406414
"""Test that Cuga component has the correct output configuration.

src/lfx/src/lfx/components/agents/cuga_agent.py

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import asyncio
22
import json
3-
import os
43
import re
54
import traceback
65
import uuid
@@ -108,9 +107,9 @@ class CugaComponent(ToolCallingAgentComponent):
108107
info=(
109108
"Custom instructions or policies for the agent to adhere to during its operation.\n"
110109
"Example:\n"
111-
"# Plan\n"
110+
"## Plan\n"
112111
"< planning instructions e.g. which tools and when to use>\n"
113-
"# Answer\n"
112+
"## Answer\n"
114113
"< final answer instructions how to answer>"
115114
),
116115
value="",
@@ -193,6 +192,20 @@ class CugaComponent(ToolCallingAgentComponent):
193192
info="If true, will add a tool to the agent that returns the current date.",
194193
value=True,
195194
),
195+
BoolInput(
196+
name="lite_mode",
197+
display_name="Enable CugaLite",
198+
info="Enable CugaLite for simple API tasks (faster execution).",
199+
value=True,
200+
advanced=False,
201+
),
202+
IntInput(
203+
name="lite_mode_tool_threshold",
204+
display_name="CugaLite Tool Threshold",
205+
info="Route to CugaLite if app has fewer than this many tools.",
206+
value=25,
207+
advanced=False,
208+
),
196209
BoolInput(
197210
name="browser_enabled",
198211
display_name="Enable Browser",
@@ -254,33 +267,27 @@ async def call_agent(
254267
}
255268
logger.debug(f"LLM MODEL TYPE: {type(llm)}")
256269
if current_input:
257-
try:
258-
from cuga.config import settings as cuga_settings
270+
# Import settings first
271+
from cuga.config import settings
259272

260-
logger.info("Updating cuga settings programmatically")
261-
cuga_settings.set("advanced_features.registry", False) # noqa: FBT003
273+
# Use Dynaconf's set() method to update settings dynamically
274+
# This properly updates the settings object without corruption
275+
logger.debug("Updating CUGA settings via Dynaconf set() method")
262276

263-
if self.browser_enabled:
264-
logger.info("browser_enabled is true, setting mode to hybrid")
265-
cuga_settings.set("advanced_features.mode", "hybrid")
266-
cuga_settings.set("advanced_features.use_vision", False) # noqa: FBT003
267-
else:
268-
logger.info("browser_enabled is false, setting mode to api")
269-
cuga_settings.set("advanced_features.mode", "api")
270-
271-
logger.info(f"Cuga settings updated - MODE: {cuga_settings.get('advanced_features.mode')}")
272-
except (ImportError, AttributeError) as e:
273-
logger.warning(f"Could not update cuga settings: {e}")
274-
os.environ["DYNACONF_ADVANCED_FEATURES__REGISTRY"] = "false"
275-
if self.browser_enabled:
276-
logger.info("browser_enabled is true, setting env to hybrid")
277-
os.environ["DYNACONF_ADVANCED_FEATURES__MODE"] = "hybrid"
278-
os.environ["DYNACONF_ADVANCED_FEATURES__USE_VISION"] = "false"
279-
else:
280-
logger.info("browser_enabled is false, setting env to api")
281-
os.environ["DYNACONF_ADVANCED_FEATURES__MODE"] = "api"
277+
settings.advanced_features.registry = False
278+
settings.advanced_features.lite_mode = self.lite_mode
279+
settings.advanced_features.lite_mode_tool_threshold = self.lite_mode_tool_threshold
280+
281+
if self.browser_enabled:
282+
logger.info("browser_enabled is true, setting mode to hybrid")
283+
settings.advanced_features.mode = "hybrid"
284+
settings.advanced_features.use_vision = False
285+
else:
286+
logger.info("browser_enabled is false, setting mode to api")
287+
settings.advanced_features.mode = "api"
282288

283289
from cuga.backend.activity_tracker.tracker import ActivityTracker
290+
from cuga.backend.cuga_graph.nodes.api.variables_manager.manager import VariablesManager
284291
from cuga.backend.cuga_graph.utils.agent_loop import StreamEvent
285292
from cuga.backend.cuga_graph.utils.controller import (
286293
AgentRunner as CugaAgent,
@@ -291,6 +298,16 @@ async def call_agent(
291298
from cuga.backend.llm.models import LLMManager
292299
from cuga.configurations.instructions_manager import InstructionsManager
293300

301+
var_manager = VariablesManager()
302+
303+
# Reset var_manager if this is the first message in history
304+
logger.info(f"[CUGA] Checking history_messages: count={len(history_messages) if history_messages else 0}")
305+
if not history_messages or len(history_messages) == 0:
306+
logger.info("[CUGA] First message in history detected, resetting var_manager")
307+
var_manager.reset()
308+
else:
309+
logger.info(f"[CUGA] Continuing conversation with {len(history_messages)} previous messages")
310+
294311
llm_manager = LLMManager()
295312
llm_manager.set_llm(llm)
296313
instructions_manager = InstructionsManager()
@@ -760,11 +777,13 @@ async def get_memory_data(self):
760777
list: List of Message objects representing the chat history
761778
"""
762779
logger.info("[CUGA] Retrieving chat history messages.")
780+
logger.info(f"[CUGA] Session ID: {self.graph.session_id}")
763781
messages = (
764782
await MemoryComponent(**self.get_base_args())
765783
.set(session_id=self.graph.session_id, order="Ascending", n_messages=self.n_messages)
766784
.retrieve_messages()
767785
)
786+
logger.info(f"[CUGA] Retrieved {len(messages)} messages from memory")
768787
return [
769788
message for message in messages if getattr(message, "id", None) != getattr(self.input_value, "id", None)
770789
]

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)