langflow icon indicating copy to clipboard operation
langflow copied to clipboard

feat: agentic UX

Open edwinjosechittilappilly opened this issue 1 year ago • 9 comments

This pull request introduces several new modules and utilities to support agentic features in Langflow, including component search, template utilities, and support functions. It also adds onboarding and guidance "nudges" to the agentic schema for improved user experience. The changes are grouped into new backend functionalities, schema enhancements, and utility additions.

New backend agentic functionalities:

  • Added component_search.py with asynchronous utilities for searching, filtering, and retrieving Langflow components by name, type, and metadata fields, including error handling and documentation.
  • Added support.py with a function to normalize data dictionaries by replacing missing or invalid values (None, 'null', NaN, etc.) with a "Not available" string and ensuring required fields are present.

Agentic schema enhancements:

  • Introduced schema.json defining a set of "nudges"—onboarding prompts and quick actions for the Langflow Assistant UI, such as navigation to onboarding, creating flows, browsing components, exploring templates, reading docs, and sharing feedback.

Utility and module structure improvements:

  • Added utils/__init__.py to expose template search utilities for agentic features, including functions for listing templates and retrieving tags/counts.
  • Added module docstrings and initialization files for langflow.agentic and its submodules to clarify their purpose and improve maintainability. [1] [2]

Entrypoint for MCP server:

  • Added mcp/__main__.py to provide a Python module entrypoint for running the Langflow Agentic MCP server via python -m langflow.agentic.mcp.

Summary by CodeRabbit

  • New Features

    • Added AI-powered agentic server with tools to search templates, discover components, and inspect flows.
    • Introduced Assistant button for AI-assisted field value suggestions in the UI.
    • Created Langflow Assistant folder for pre-built flows and enhanced onboarding.
  • Chores

    • Auto-configured agentic features during application startup.
    • Enhanced template and component discovery utilities.

edwinjosechittilappilly avatar Nov 11 '25 20:11 edwinjosechittilappilly

[!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.

[!NOTE]

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Introduces a comprehensive agentic experience module for Langflow, including an MCP (Model Context Protocol) server, assistant UI components for field-level and header integration, utilities for template and component searching, flow manipulation capabilities, and supporting infrastructure for per-user agentic variables and MCP server configuration.

Changes

Cohort / File(s) Summary
Backend - Agentic MCP Module
src/backend/base/langflow/agentic/__init__.py, src/backend/base/langflow/agentic/mcp/__init__.py, src/backend/base/langflow/agentic/mcp/__main__.py
Package structure for agentic module with MCP server entry point and re-export; enables running MCP server via python -m langflow.agentic.mcp.
Backend - MCP Server & Support
src/backend/base/langflow/agentic/mcp/server.py, src/backend/base/langflow/agentic/mcp/support.py
FastMCP server exposing 18+ tools for template/component/flow queries, field manipulation, and graph visualization; support utility normalizes null/NaN values in dict lists.
Backend - Agentic Utilities
src/backend/base/langflow/agentic/utils/(template_search|component_search|flow_component|flow_graph|template_create).py
Utilities for searching templates/components, retrieving component/flow details, updating flow component fields, and creating flows from templates.
Backend - UI Schema
src/backend/base/langflow/agentic/schema/schema.json
JSON schema defining seven UI nudges (onboarding, flow creation, component browsing, template exploration, docs, feedback).
Backend - API Integration
src/backend/base/langflow/api/utils/mcp/agentic_mcp.py
Auto-configures/removes agentic MCP servers per user; initializes per-user and global agentic variables.
Backend - Endpoint & Auth Updates
src/backend/base/langflow/api/v1/endpoints.py, src/backend/base/langflow/api/v1/login.py
Refactors flow execution into _run_flow_internal with wrapper endpoints for API-key and session auth; integrates agentic initialization on login.
Backend - Project & Setup
src/backend/base/langflow/api/v1/projects.py, src/backend/base/langflow/initial_setup/constants.py, src/backend/base/langflow/initial_setup/setup.py
Prevents deletion of Assistant folder; adds ASSISTANT_FOLDER constants; introduces agentic folder/flow initialization on startup.
Backend - Startup & Configuration
src/backend/base/langflow/main.py
Conditionally initializes agentic global variables and MCP server on startup when agentic_experience is enabled.
Backend - Tests
src/backend/tests/unit/agentic/*, src/backend/tests/unit/components/models_and_agents/test_agent_component.py
Comprehensive unit tests for template search utilities; test for multimodal agent message handling.
Starter Templates
src/backend/base/langflow/initial_setup/starter_projects/Nvidia Remix.json
Formatting normalization (multi-line arrays → single-line compact format); no semantic changes.
Frontend - Assistant UI Component
src/frontend/src/components/common/assistant/index.tsx
New AssistantButton component supporting field, flow, project, and header modes; integrates with assistant prompt query and sidebar toggle.
Frontend - Header & Field Integration
src/frontend/src/components/core/appHeaderComponent/index.tsx, src/frontend/src/CustomNodes/GenericNode/components/NodeInputField/index.tsx
Renders AssistantButton in app header and conditionally in node input fields when ai_enabled is true.
Frontend - API Constants & Queries
src/frontend/src/controllers/API/helpers/constants.ts, src/frontend/src/controllers/API/queries/assistant/use-get-assistant-prompt.ts, src/frontend/src/controllers/API/queries/assistant/index.ts
Adds RUN and RUN_SESSION URL constants; introduces useGetAssistantPromptQuery hook for POST requests with agentic-context headers.
Frontend - State Management
src/frontend/src/stores/assistantManagerStore.ts, src/frontend/src/types/zustand/assistantManager/index.ts
Zustand store for assistant manager with flow/component context, undo/redo history per flow, UI state toggles, and chat session management.
LFX Package - Input & Component Updates
src/lfx/src/lfx/inputs/input_mixin.py, src/lfx/src/lfx/inputs/inputs.py, src/lfx/src/lfx/components/models_and_agents/mcp_component.py
Adds AIMixin for AI-enabled field flag; extends MultilineInput with AIMixin; adds process_output_item method to MCPToolsComponent for JSON text parsing.
LFX Package - Settings
src/lfx/src/lfx/services/settings/base.py, src/lfx/src/lfx/services/settings/constants.py
Adds AGENTIC_VARIABLES constant and agentic_experience boolean setting; enhances environment variable validation for agentic context.

Sequence Diagram(s)

sequenceDiagram
    participant App as Langflow App
    participant UI as Frontend UI
    participant API as Backend API
    participant DB as Database
    participant MCP as MCP Server
    
    Note over App: Startup Phase
    App->>API: lifespan startup
    API->>DB: initialize_agentic_global_variables
    API->>DB: auto_configure_agentic_mcp_server
    
    Note over UI,MCP: User Login Phase
    UI->>API: login_to_get_access_token
    API->>DB: initialize_agentic_user_variables
    API->>DB: create_or_update_agentic_flows
    
    Note over UI,API: Assistant Interaction Phase
    UI->>UI: User clicks AssistantButton (field mode)
    UI->>API: POST /run/session with TemplateAssistant<br/>(X-Langflow-Global-Var headers)
    API->>MCP: Query component/template/flow context
    MCP->>DB: Search templates, get components, visualize flow
    MCP-->>API: Return context data
    API-->>UI: Stream assistant prompt response
    UI->>UI: Update field value via handleOnNewValue
sequenceDiagram
    participant User as User
    participant Frontend as Frontend Store
    participant AssistantStore as AssistantManager Store
    participant FlowStore as Flow Store
    
    Note over AssistantStore: Undo/Redo Flow
    User->>Frontend: Edit flow (add/modify node)
    Frontend->>AssistantStore: takeSnapshot()
    AssistantStore->>FlowStore: Clone nodes/edges
    AssistantStore->>AssistantStore: Push to past[] (maintain maxHistorySize)
    
    User->>Frontend: Click Undo
    Frontend->>AssistantStore: undo()
    AssistantStore->>AssistantStore: Pop from past[], push to future[]
    AssistantStore->>FlowStore: setNodes/setEdges(previous state)
    FlowStore-->>Frontend: Render reverted flow

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Areas requiring extra attention:

  • src/backend/base/langflow/agentic/mcp/server.py: High-complexity MCP server with 18+ exposed tool functions, mixed sync/async signatures, integration with database sessions, and intricate flow/component data retrieval logic. Verify correct async handling, SettingsService initialization patterns, and error propagation.
  • src/backend/base/langflow/agentic/utils/flow_component.py: Complex flow introspection with database persistence (update_component_field_value), graph traversal, and serialization edge cases. Verify field validation, transaction safety, and error messages.
  • src/backend/base/langflow/api/utils/mcp/agentic_mcp.py: Per-user MCP server setup and variable initialization with comprehensive error handling across users. Verify robustness to per-user failures and correct settings_service gating.
  • src/frontend/src/stores/assistantManagerStore.ts: Complex Zustand store with per-flow undo/redo history management using global past/future maps. Verify snapshot consistency, memory management for history bounds, and state isolation between flows.
  • src/backend/base/langflow/api/v1/login.py and src/backend/base/langflow/main.py: Startup/login hooks affecting application initialization order. Verify no race conditions with agentic initialization, telemetry, and MCP composer startup sequencing.
  • src/backend/base/langflow/agentic/utils/component_search.py: Async component querying with lazy SettingsService initialization and cached types dictionary dependency. Verify cache invalidation behavior and error handling patterns.

Possibly related PRs

  • langflow-ai/langflow#9889: Both PRs modify MCP/agentic startup and settings surfaces (startup initialization in main.py, agentic settings like AGENTIC_VARIABLES/agentic_experience, and MCP server auto-configuration).
  • langflow-ai/langflow#8729: Both PRs modify MCPToolsComponent to handle Message objects and their text extraction in tool I/O processing.
  • langflow-ai/langflow#8735: This PR adds agentic component search utilities that call get_and_cache_all_types_dict, while the related PR modifies component-loading/caching behavior.

Suggested reviewers

  • Cristhianzl

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)
Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error Pull request adds 12+ backend modules and 5+ frontend components with 40+ public functions but provides test coverage for only ~7-8% of new code, with zero frontend tests. Add comprehensive tests for MCP server (18+ functions), utility modules (component_search, flow_component, flow_graph, template_create, support), modified APIs, and all frontend components/hooks/stores using appropriate testing frameworks and mocking strategies.
Test Quality And Coverage ⚠️ Warning Only 4 of 39 new functions have test coverage (10.3%), with 13+ async functions and all MCP server endpoints completely untested. Add comprehensive unit and async tests for component_search, flow_graph, flow_component, template_create, and all 16 MCP server functions; create frontend tests for AssistantButton and assistantManagerStore components.
Test File Naming And Structure ⚠️ Warning Test method test_agent_handles_multimodal_message_input in test_agent_component.py violates testing best practices by testing internal utility methods instead of component interface, uses non-multimodal message creation, and lacks proper assertions for agent extraction logic verification. Restructure test to use component.input_value, create actual multimodal Message with files, add comprehensive assertions validating agent extraction logic per existing test patterns.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: agentic UX' is concise and clearly signals a feature addition focused on agentic user experience improvements. However, it is somewhat broad and generic—it refers to the domain (agentic UX) but does not capture the most specific or primary changes (e.g., MCP server, component search, schema, utilities).
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.
Excessive Mock Usage Warning ✅ Passed Test files demonstrate minimal mock usage with real templates and Message objects; integration-style testing approach validates actual functionality rather than mocked behavior.

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.

coderabbitai[bot] avatar Nov 11 '25 20:11 coderabbitai[bot]

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 15%
14.58% (3986/27321) 7.5% (1560/20773) 8.88% (535/6021)

Unit Test Results

Tests Skipped Failures Errors Time
1630 0 :zzz: 0 :x: 0 :fire: 18.566s :stopwatch:

github-actions[bot] avatar Nov 13 '25 20:11 github-actions[bot]

Codecov Report

:x: Patch coverage is 11.73913% with 812 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 30.01%. Comparing base (f174556) to head (743d680).

Files with missing lines Patch % Lines
...backend/base/langflow/api/utils/mcp/agentic_mcp.py 12.78% 116 Missing :warning:
...kend/base/langflow/agentic/utils/flow_component.py 0.00% 111 Missing :warning:
...nd/base/langflow/agentic/utils/component_search.py 0.00% 101 Missing :warning:
src/backend/base/langflow/agentic/mcp/server.py 0.00% 88 Missing :warning:
...frontend/src/components/common/assistant/index.tsx 0.00% 71 Missing :warning:
src/backend/base/langflow/initial_setup/setup.py 11.39% 70 Missing :warning:
src/frontend/src/stores/assistantManagerStore.ts 0.00% 57 Missing :warning:
.../backend/base/langflow/agentic/utils/flow_graph.py 0.00% 53 Missing :warning:
src/backend/base/langflow/agentic/mcp/support.py 0.00% 33 Missing :warning:
...end/base/langflow/agentic/utils/template_create.py 0.00% 26 Missing :warning:
... and 12 more

:x: Your patch check has failed because the patch coverage (11.73%) is below the target coverage (40.00%). You can increase the patch coverage or adjust the target coverage. :x: Your project check has failed because the head coverage (44.96%) is below the target coverage (55.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #10567      +/-   ##
==========================================
- Coverage   31.62%   30.01%   -1.62%     
==========================================
  Files        1350     1364      +14     
  Lines       61154    62064     +910     
  Branches     9142     9180      +38     
==========================================
- Hits        19341    18628     -713     
- Misses      40897    42518    +1621     
- Partials      916      918       +2     
Flag Coverage Δ
backend 44.96% <12.99%> (-6.82%) :arrow_down:
frontend 13.51% <0.59%> (-0.09%) :arrow_down:
lfx 38.97% <91.66%> (+0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...c/backend/base/langflow/initial_setup/constants.py 100.00% <100.00%> (ø)
.../frontend/src/controllers/API/helpers/constants.ts 55.55% <ø> (ø)
src/frontend/src/customization/feature-flags.ts 100.00% <100.00%> (ø)
src/lfx/src/lfx/inputs/input_mixin.py 82.68% <100.00%> (+0.15%) :arrow_up:
src/lfx/src/lfx/inputs/inputs.py 68.37% <100.00%> (ø)
src/lfx/src/lfx/services/settings/constants.py 100.00% <100.00%> (ø)
src/backend/base/langflow/api/v1/endpoints.py 47.35% <85.71%> (-24.80%) :arrow_down:
src/lfx/src/lfx/services/settings/base.py 69.83% <87.50%> (+0.19%) :arrow_up:
...end/src/controllers/API/queries/assistant/index.ts 0.00% <0.00%> (ø)
src/backend/base/langflow/agentic/mcp/__main__.py 0.00% <0.00%> (ø)
... and 18 more

... and 57 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Nov 13 '25 20:11 codecov[bot]

Build successful! :white_check_mark: Deploying docs draft. Deploy successful! View draft

github-actions[bot] avatar Nov 13 '25 20:11 github-actions[bot]

Build successful! :white_check_mark: Deploying docs draft.

github-actions[bot] avatar Nov 13 '25 20:11 github-actions[bot]

Build successful! :white_check_mark: Deploying docs draft. Deploy successful! View draft

github-actions[bot] avatar Nov 13 '25 20:11 github-actions[bot]

@coderabbitai full review

Adam-Aghili avatar Nov 14 '25 17:11 Adam-Aghili

✅ Actions performed

Full review triggered.

coderabbitai[bot] avatar Nov 14 '25 17:11 coderabbitai[bot]

feature flagged version of Agentic UX @Cristhianzl @lucaseduoli Merging since PR was getting larger.

edwinjosechittilappilly avatar Nov 14 '25 20:11 edwinjosechittilappilly

test_dynamic_module_discovery passes locally but fails in CI.

edwinjosechittilappilly avatar Nov 18 '25 04:11 edwinjosechittilappilly

Backend Fix: https://github.com/langflow-ai/langflow/pull/10636

edwinjosechittilappilly avatar Nov 18 '25 05:11 edwinjosechittilappilly

@edwinjosechittilappilly the frontend tests are flaky so if we re run it will eventually pass. I don't know if we want to address that in this issue. Even with the wait for load sometiems the tools is not available. we could also increase the retries but that would increase our already long CI time

Adam-Aghili avatar Nov 20 '25 15:11 Adam-Aghili