Skip to content

Conversation

@sami-marreed
Copy link
Contributor

@sami-marreed sami-marreed commented Nov 11, 2025

Summary by CodeRabbit

  • New Features

    • Added lite_mode configuration option to Cuga agent component
    • Added lite_mode_tool_threshold setting to Cuga agent component
  • Chores

    • Updated dependency to version 0.1.4

@github-actions github-actions bot added the community Pull Request from an external contributor label Nov 11, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Bumps cuga dependency from 0.1.2 to 0.1.4. Adds two new configuration inputs (lite_mode and lite_mode_tool_threshold) to CugaComponent. Refactors settings assignment from dynamic Dynaconf updates to direct attribute assignments. Introduces VariablesManager instantiation during agent calls and enhances logging for memory and session tracking.

Changes

Cohort / File(s) Summary
Dependency Update
pyproject.toml
Upgrades cuga dependency from 0.1.2 to 0.1.4
Test Updates
src/backend/tests/unit/components/agents/test_cuga_agent.py
Adds test coverage for two new CugaComponent inputs: lite_mode (BoolInput, default True) and lite_mode_tool_threshold (IntInput, default 25); updates assertions to verify presence and default values
Component Implementation
src/lfx/src/lfx/components/agents/cuga_agent.py
Adds lite_mode and lite_mode_tool_threshold public inputs; replaces dynamic Dynaconf set() calls with direct attribute assignments for settings.advanced_features.*; introduces VariablesManager instantiation with reset logic for first messages; adds logging for session ID and retrieved message counts

Sequence Diagram

sequenceDiagram
    participant User as User/Frontend
    participant Component as CugaComponent
    participant VariablesMgr as VariablesManager
    participant CugaSettings as Cuga Settings
    participant Agent as Cuga Agent

    User->>Component: call_agent(message, browser_enabled, lite_mode, ...)
    
    rect rgb(200, 220, 255)
    Note over Component: Configuration Phase
    Component->>CugaSettings: Direct assign settings.advanced_features.*
    Component->>CugaSettings: Set lite_mode, lite_mode_tool_threshold
    Component->>CugaSettings: Conditionally set mode & use_vision
    end
    
    rect rgb(220, 200, 255)
    Note over Component: Variables Management
    Component->>VariablesMgr: Instantiate VariablesManager()
    alt First Message (no history)
        Component->>VariablesMgr: reset()
        VariablesMgr-->>Component: Cleared state
    else Has History
        Component->>Component: Log message count from history
    end
    end
    
    Component->>Agent: Execute with configured settings
    Agent-->>Component: Response
    Component-->>User: Return result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Settings refactoring: Verify that direct attribute assignments replace Dynaconf set() behavior correctly and maintain configuration integrity
  • VariablesManager lifecycle: Confirm that instantiation and reset() logic aligns with intended memory/state management during multi-turn conversations
  • New inputs propagation: Ensure lite_mode and lite_mode_tool_threshold flow correctly through component initialization and CugaComponent configuration in tests

Possibly related PRs

Suggested labels

enhancement, lgtm

Suggested reviewers

  • ogabrielluiz
  • edwinjosechittilappilly

Pre-merge checks and finishing touches

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error Test coverage focuses on new input fields (lite_mode, lite_mode_tool_threshold) but does not cover runtime behavior changes including VariablesManager management, settings attribute assignment refactoring, or new logging enhancements. Add tests for VariablesManager instantiation/reset, refactored settings assignment, conditional mode setup, and memory retrieval logging to comprehensively cover the behavioral changes introduced in this PR.
Test Quality And Coverage ⚠️ Warning Tests verify presence and default values of new lite_mode and lite_mode_tool_threshold inputs, but lack behavioral testing for their actual functionality, edge cases, async patterns, and VariablesManager integration. Add tests for lite_mode behavior changes, lite_mode_tool_threshold edge cases, VariablesManager.reset() calls, async call patterns with pytest.mark.asyncio, and integration tests verifying combined functionality.
Test File Naming And Structure ⚠️ Warning PR summary claims test file modifications at src/backend/tests/unit/components/agents/test_cuga_agent.py, but this file does not exist in the repository. Create test file with descriptive test function names verifying new lite_mode and lite_mode_tool_threshold inputs and their configurations.
Title check ❓ Inconclusive The title 'feat(cuga): new cuga release' is vague and doesn't convey specific information about what changed in the cuga component beyond a version bump. Consider a more descriptive title like 'feat(cuga): add lite_mode configuration and update to 0.1.4' to clarify the main changes (new inputs and dependency bump).
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Excessive Mock Usage Warning ✅ Passed The test file appropriately uses mocks for external dependencies and API calls while maintaining focus on the component's core logic and configuration.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 11, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lfx/src/lfx/components/agents/cuga_agent.py (1)

290-310: var_manager is instantiated and reset but never used afterward—confirmed as dead code.

The complete file search confirms var_manager appears only at lines 301 (instantiation), 303 (comment), 306 (log), and 307 (reset call). It is never passed to CugaAgent, stored as an instance variable, or referenced after line 307. Either pass var_manager to CugaAgent or remove the unused initialization and reset logic.

🧹 Nitpick comments (1)
src/lfx/src/lfx/components/agents/cuga_agent.py (1)

304-305: Simplify redundant condition check.

The condition if not history_messages or len(history_messages) == 0 is redundant since not history_messages already evaluates to True for empty lists.

Apply this diff to simplify:

-            if not history_messages or len(history_messages) == 0:
+            if not history_messages:
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91d73e7 and 007aff5.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • pyproject.toml (1 hunks)
  • src/backend/tests/unit/components/agents/test_cuga_agent.py (3 hunks)
  • src/lfx/src/lfx/components/agents/cuga_agent.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
src/backend/tests/unit/components/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)

src/backend/tests/unit/components/**/*.py: Mirror the component directory structure for unit tests in src/backend/tests/unit/components/
Use ComponentTestBaseWithClient or ComponentTestBaseWithoutClient as base classes for component unit tests
Provide file_names_mapping for backward compatibility in component tests
Create comprehensive unit tests for all new components

Files:

  • src/backend/tests/unit/components/agents/test_cuga_agent.py
{src/backend/**/*.py,tests/**/*.py,Makefile}

📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)

{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code

Files:

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

📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)

Test component integration within flows using create_flow, build_flow, and get_build_events utilities

Files:

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

📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)

src/backend/tests/**/*.py: Unit tests for backend code must be located in the 'src/backend/tests/' directory, with component tests organized by component subdirectory under 'src/backend/tests/unit/components/'.
Test files should use the same filename as the component under test, with an appropriate test prefix or suffix (e.g., 'my_component.py' → 'test_my_component.py').
Use the 'client' fixture (an async httpx.AsyncClient) for API tests in backend Python tests, as defined in 'src/backend/tests/conftest.py'.
When writing component tests, inherit from the appropriate base class in 'src/backend/tests/base.py' (ComponentTestBase, ComponentTestBaseWithClient, or ComponentTestBaseWithoutClient) and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping'.
Each test in backend Python test files should have a clear docstring explaining its purpose, and complex setups or mocks should be well-commented.
Test both sync and async code paths in backend Python tests, using '@pytest.mark.asyncio' for async tests.
Mock external dependencies appropriately in backend Python tests to isolate unit tests from external services.
Test error handling and edge cases in backend Python tests, including using 'pytest.raises' and asserting error messages.
Validate input/output behavior and test component initialization and configuration in backend Python tests.
Use the 'no_blockbuster' pytest marker to skip the blockbuster plugin in tests when necessary.
Be aware of ContextVar propagation in async tests; test both direct event loop execution and 'asyncio.to_thread' scenarios to ensure proper context isolation.
Test error handling by mocking internal functions using monkeypatch in backend Python tests.
Test resource cleanup in backend Python tests by using fixtures that ensure proper initialization and cleanup of resources.
Test timeout and performance constraints in backend Python tests using 'asyncio.wait_for' and timing assertions.
Test Langflow's Messag...

Files:

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

📄 CodeRabbit inference engine (.cursor/rules/icons.mdc)

In your Python component class, set the icon attribute to a string matching the frontend icon mapping exactly (case-sensitive).

Files:

  • src/backend/tests/unit/components/agents/test_cuga_agent.py
🧠 Learnings (2)
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test component configuration updates in backend Python tests by asserting correct updates to build configuration objects.

Applied to files:

  • src/backend/tests/unit/components/agents/test_cuga_agent.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Create comprehensive unit tests for all new components

Applied to files:

  • src/backend/tests/unit/components/agents/test_cuga_agent.py
🧬 Code graph analysis (1)
src/lfx/src/lfx/components/agents/cuga_agent.py (4)
src/lfx/src/lfx/inputs/inputs.py (2)
  • BoolInput (414-426)
  • IntInput (344-376)
src/lfx/src/lfx/graph/graph/base.py (2)
  • session_id (168-169)
  • session_id (172-173)
src/lfx/src/lfx/components/helpers/memory.py (2)
  • MemoryComponent (16-268)
  • retrieve_messages (190-240)
src/lfx/src/lfx/custom/custom_component/component.py (1)
  • get_base_args (268-281)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
  • GitHub Check: Run Backend Tests / LFX Tests - Python 3.10
  • GitHub Check: Lint Backend / Run Mypy (3.11)
  • GitHub Check: Lint Backend / Run Mypy (3.12)
  • GitHub Check: Lint Backend / Run Mypy (3.10)
  • GitHub Check: Lint Backend / Run Mypy (3.13)
  • GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
  • GitHub Check: Test Starter Templates
  • GitHub Check: Update Component Index
  • GitHub Check: Update Starter Projects
🔇 Additional comments (6)
src/lfx/src/lfx/components/agents/cuga_agent.py (3)

195-208: LGTM! New CugaLite inputs are properly defined.

The lite_mode and lite_mode_tool_threshold inputs are correctly typed with appropriate defaults and user-facing descriptions.


780-780: LGTM! Enhanced logging for session tracking.

Adding session_id logging improves observability for debugging conversation flows.


786-786: LGTM! Enhanced logging for memory retrieval.

Logging the message count helps track conversation history size for debugging.

src/backend/tests/unit/components/agents/test_cuga_agent.py (2)

75-76: LGTM! Test coverage for new inputs.

The test properly includes the new lite_mode and lite_mode_tool_threshold parameters with their expected default values.


394-411: LGTM! Comprehensive validation of new input fields.

The test properly verifies:

  • New fields are present in input names
  • Component has the corresponding attributes
  • Default values are correct (lite_mode=True, lite_mode_tool_threshold=25)

This follows the established testing pattern and ensures the new inputs are properly configured.

pyproject.toml (1)

137-137: No issues found with cuga==0.1.4 dependency update.

Version 0.1.4 exists on PyPI and is the latest available version. No known security vulnerabilities were found for the cuga package. The patch version bump (0.1.2 → 0.1.4) is safe to merge.

Comment on lines +270 to 288
# Import settings first
from cuga.config import settings

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

if self.browser_enabled:
logger.info("browser_enabled is true, setting mode to hybrid")
cuga_settings.set("advanced_features.mode", "hybrid")
cuga_settings.set("advanced_features.use_vision", False) # noqa: FBT003
else:
logger.info("browser_enabled is false, setting mode to api")
cuga_settings.set("advanced_features.mode", "api")

logger.info(f"Cuga settings updated - MODE: {cuga_settings.get('advanced_features.mode')}")
except (ImportError, AttributeError) as e:
logger.warning(f"Could not update cuga settings: {e}")
os.environ["DYNACONF_ADVANCED_FEATURES__REGISTRY"] = "false"
if self.browser_enabled:
logger.info("browser_enabled is true, setting env to hybrid")
os.environ["DYNACONF_ADVANCED_FEATURES__MODE"] = "hybrid"
os.environ["DYNACONF_ADVANCED_FEATURES__USE_VISION"] = "false"
else:
logger.info("browser_enabled is false, setting env to api")
os.environ["DYNACONF_ADVANCED_FEATURES__MODE"] = "api"
settings.advanced_features.registry = False
settings.advanced_features.lite_mode = self.lite_mode
settings.advanced_features.lite_mode_tool_threshold = self.lite_mode_tool_threshold

if self.browser_enabled:
logger.info("browser_enabled is true, setting mode to hybrid")
settings.advanced_features.mode = "hybrid"
settings.advanced_features.use_vision = False
else:
logger.info("browser_enabled is false, setting mode to api")
settings.advanced_features.mode = "api"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Comment claims to use Dynaconf's set() method, but code uses direct attribute assignment.

The comment states "Use Dynaconf's set() method to update settings dynamically" but the implementation uses direct attribute assignment (e.g., settings.advanced_features.registry = False). Either update the comment to reflect the actual implementation or switch to using Dynaconf's set() method if that's the intended approach.

If direct assignment is correct, apply this diff:

-            # Use Dynaconf's set() method to update settings dynamically
-            # This properly updates the settings object without corruption
-            logger.debug("Updating CUGA settings via Dynaconf set() method")
+            # Update CUGA settings via direct attribute assignment
+            logger.debug("Updating CUGA advanced_features settings")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Import settings first
from cuga.config import settings
logger.info("Updating cuga settings programmatically")
cuga_settings.set("advanced_features.registry", False) # noqa: FBT003
# Use Dynaconf's set() method to update settings dynamically
# This properly updates the settings object without corruption
logger.debug("Updating CUGA settings via Dynaconf set() method")
if self.browser_enabled:
logger.info("browser_enabled is true, setting mode to hybrid")
cuga_settings.set("advanced_features.mode", "hybrid")
cuga_settings.set("advanced_features.use_vision", False) # noqa: FBT003
else:
logger.info("browser_enabled is false, setting mode to api")
cuga_settings.set("advanced_features.mode", "api")
logger.info(f"Cuga settings updated - MODE: {cuga_settings.get('advanced_features.mode')}")
except (ImportError, AttributeError) as e:
logger.warning(f"Could not update cuga settings: {e}")
os.environ["DYNACONF_ADVANCED_FEATURES__REGISTRY"] = "false"
if self.browser_enabled:
logger.info("browser_enabled is true, setting env to hybrid")
os.environ["DYNACONF_ADVANCED_FEATURES__MODE"] = "hybrid"
os.environ["DYNACONF_ADVANCED_FEATURES__USE_VISION"] = "false"
else:
logger.info("browser_enabled is false, setting env to api")
os.environ["DYNACONF_ADVANCED_FEATURES__MODE"] = "api"
settings.advanced_features.registry = False
settings.advanced_features.lite_mode = self.lite_mode
settings.advanced_features.lite_mode_tool_threshold = self.lite_mode_tool_threshold
if self.browser_enabled:
logger.info("browser_enabled is true, setting mode to hybrid")
settings.advanced_features.mode = "hybrid"
settings.advanced_features.use_vision = False
else:
logger.info("browser_enabled is false, setting mode to api")
settings.advanced_features.mode = "api"
# Import settings first
from cuga.config import settings
# Update CUGA settings via direct attribute assignment
logger.debug("Updating CUGA advanced_features settings")
settings.advanced_features.registry = False
settings.advanced_features.lite_mode = self.lite_mode
settings.advanced_features.lite_mode_tool_threshold = self.lite_mode_tool_threshold
if self.browser_enabled:
logger.info("browser_enabled is true, setting mode to hybrid")
settings.advanced_features.mode = "hybrid"
settings.advanced_features.use_vision = False
else:
logger.info("browser_enabled is false, setting mode to api")
settings.advanced_features.mode = "api"
🤖 Prompt for AI Agents
In src/lfx/src/lfx/components/agents/cuga_agent.py around lines 270-288, the
inline comment claims Dynaconf's set() is used but the code performs direct
attribute assignment; update the comment to accurately state that settings are
modified via direct attribute assignment (or, if you intended to use Dynaconf
set(), replace the assignments with settings.set(...) calls for each key),
ensuring the comment and implementation match.

@sami-marreed sami-marreed force-pushed the bugfix/cuga-new-release branch from 2b62674 to 74dfaf1 Compare November 11, 2025 13:33
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 11, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 11, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 11, 2025
.set(session_id=self.graph.session_id, order="Ascending", n_messages=self.n_messages)
.retrieve_messages()
)
logger.info(f"[CUGA] Retrieved {len(messages)} messages from memory")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move most of these types of logs to debug

name="agent_llm",
display_name="Model Provider",
info="The provider of the language model that the agent will use to generate responses.",
options=[*MODEL_PROVIDERS_LIST, "Custom"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we tested with non-openai models?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested manually not in test here, mainly on watsonx and openai

auto-merge was automatically disabled November 11, 2025 21:34

Head branch was pushed to by a user without write access

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 11, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 11, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 11, 2025
@jordanrfrazier jordanrfrazier added this pull request to the merge queue Nov 11, 2025
Merged via the queue into langflow-ai:main with commit b535950 Nov 11, 2025
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Pull Request from an external contributor enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants