-
Notifications
You must be signed in to change notification settings - Fork 8.2k
feat(cuga): new cuga release #10559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cuga): new cuga release #10559
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughBumps cuga dependency from 0.1.2 to 0.1.4. Adds two new configuration inputs ( Changes
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touchesImportant Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 2 warnings, 1 inconclusive)
✅ Passed checks (3 passed)
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. Comment |
There was a problem hiding this 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) == 0is redundant sincenot history_messagesalready evaluates toTruefor 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
⛔ Files ignored due to path filters (1)
uv.lockis 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
iconattribute 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.
| # 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" | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| # 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.
2b62674 to
74dfaf1
Compare
| .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") |
There was a problem hiding this comment.
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"], |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Head branch was pushed to by a user without write access
Summary by CodeRabbit
New Features
Chores