Skip to content

Conversation

@edwinjosechittilappilly
Copy link
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly commented Dec 18, 2025

This pull request introduces a new Agentic API to the backend and improves the management and initialization of agentic variables. It also enables the agentic experience by default and adds supporting constants and test scripts. The most important changes are grouped below.

Agentic API Integration:

  • Added a new FastAPI router for agentic endpoints, including /prompt and /next_component, which execute flows using user-specific variables and OpenAI credentials (src/backend/base/langflow/agentic/api/router.py).
  • Exposed the agentic API router in the package’s __init__.py for easier imports (src/backend/base/langflow/agentic/api/__init__.py).
  • Registered the agentic router with the main API router, making agentic endpoints available under the /v2 prefix (src/backend/base/langflow/api/router.py). [1] [2]

Agentic Variable Management:

  • Refactored agentic variable initialization to dynamically use a list of variable names and a default value from new constants, and changed their type to CREDENTIAL_TYPE (src/backend/base/langflow/api/utils/mcp/agentic_mcp.py).
  • Added new agentic variable names and a default value constant (DEFAULT_AGENTIC_VARIABLE_VALUE) to the settings constants (src/lfx/src/lfx/services/settings/constants.py).

Configuration and Defaults:

  • Enabled the agentic experience by default in the settings, ensuring the agentic MCP server starts automatically (src/lfx/src/lfx/services/settings/base.py).

Testing and Utilities:

  • Added a standalone test script to run a flow using the new agentic API logic for development and debugging (src/backend/base/langflow/agentic/api/test.py).

Dependency and Import Cleanups:

  • Adjusted imports for pydantic and related dependencies for clarity and correctness in several files (src/lfx/src/lfx/custom/custom_component/custom_component.py, src/lfx/src/lfx/services/settings/base.py). [1] [2] [3] [4]

These changes collectively add agentic capabilities to the API, streamline agentic variable handling, and ensure the agentic server is enabled by default.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced Assistant Nudges feature enabling users to generate optimized prompts and discover recommended components via an interactive popover interface
    • Agentic assistant capabilities now enabled by default
  • Chores

    • Updated default configuration for agentic experience settings

✏️ Tip: You can customize this high-level summary in your review settings.

The run CLI command now accepts --env-var KEY=VALUE options to inject global variables into the graph context. Includes validation for variable format and unit tests to verify correct injection and error handling. Also improves script loading to register modules by script name for better inspection.
Updated environment variable loading logic to prioritize CLI-provided variables (request_variables in context) over OS environment variables for load_from_db fields. Added unit tests to verify correct precedence and fallback behavior.
Refactors the run CLI command to delegate execution logic to a new lfx.run.base module, improving separation of concerns and maintainability. Moves core run logic and error handling into lfx.run.base, introduces a RunError exception, and updates tests to target the new structure. Removes the --env-var option from the CLI and migrates related tests to the run module.
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 6, 2026
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 6, 2026
@edwinjosechittilappilly
Copy link
Collaborator Author

@coderabbitai create a PR summary and descriptions and changes

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

Tip

For best results, initiate chat on the files or code changes.

@edwinjosechittilappilly, here's a comprehensive PR summary and description:

PR Summary

Title: feat: Add Prompt generation Agentic Experience

This PR introduces a complete agentic experience infrastructure to Langflow, enabling AI-powered prompt generation and intelligent component suggestions through new API endpoints, flows, and UI components.


🎯 Overview

This PR adds an end-to-end agentic system that:

  • Provides intelligent prompt generation assistance to users
  • Suggests relevant components to add to flows
  • Enables AI-powered workflow building experiences
  • Makes the agentic experience available by default

🔑 Key Features

1. Agentic API Layer

  • New /agentic API router with two core endpoints:
    • POST /agentic/prompt - Generates contextual prompts based on flow and component details
    • POST /agentic/next_component - Suggests next components to add to a flow
  • Automatic OpenAI API key management via credential storage
  • Context-aware execution with flow details, component metadata, and field values

2. Frontend Assistant UI

  • AssistantNudges Component: Tabbed interface for prompt generation and component suggestions
    • PROMPT tab: Generate AI-powered prompts with live timing
    • COMPONENT tab: Display suggested components as interactive pills
  • Popover-based UI: Clean, accessible interface with proper ARIA attributes
  • Interactive Pills: Click-to-add component suggestions with automatic edge creation

3. Configuration & Variables

  • Agentic experience now enabled by default (agentic_experience: bool = True)
  • Centralized agentic variable management via constants:
    • AGENTIC_VARIABLES: List of standardized variable names
    • DEFAULT_AGENTIC_VARIABLE_VALUE: Default placeholder value
  • Variables changed from GENERIC_TYPE to CREDENTIAL_TYPE for better security

4. Prompt Generation Flow

  • New PromptGeneration.json flow definition with:
    • Chat Input/Output components
    • Language Model integration
    • Prompt Template with customizable instructions
    • Flow metadata and context injection

📁 Changes by Category

Backend API (src/backend/base/langflow/)

New Files:

  • agentic/api/router.py - Core agentic API endpoints with flow execution logic
  • agentic/api/test.py - Test script for agentic flow execution
  • agentic/flows/PromptGeneration.json - Complete flow definition for prompt generation

Modified:

  • agentic/api/__init__.py - Export router for easier imports
  • api/router.py - Removed router_v1 inclusion (moved to main.py)
  • api/__init__.py - Added router_v1 to exports
  • main.py - Conditional agentic router inclusion based on settings
  • api/utils/mcp/agentic_mcp.py - Refactored to use constants, changed to CREDENTIAL_TYPE
  • agentic/utils/flow_graph.py - Added flow_description field to graph representations

Frontend (src/frontend/src/)

New Files:

  • components/common/assistant/assistantButton.css - Styling for assistant popover
  • components/common/assistant/assistantNudgeBar/index.tsx - Main AssistantNudges component
  • components/common/assistant/assistantNudgeBar/pills.tsx - Interactive pill components
  • controllers/API/queries/assistant/use-agentic-prompt.ts - React Query hook for prompts
  • controllers/API/queries/assistant/use-suggest-next-component.ts - React Query hook for suggestions

Modified:

  • components/common/assistant/index.tsx - Added popover UI with nudges integration
  • controllers/API/helpers/constants.ts - Added AGENTIC_PROMPT URL constant, tightened types

Configuration (src/lfx/src/lfx/services/settings/)

  • base.py - Breaking Change: agentic_experience default changed from False to True
  • constants.py - Added 5 new agentic variables and default value constant

🔧 Technical Details

API Flow Execution

  1. Request received with flow_id, component_id, field_name, input_value
  2. OpenAI API key retrieved from credential storage
  3. Flow context built with metadata (FLOW_DETAILS, FIELD_VALUE, etc.)
  4. Hardcoded or dynamic flow file loaded
  5. Flow executed with run_flow() with appropriate variables
  6. Results returned or errors mapped to HTTP 500

Frontend Integration

  1. User triggers assistant via button click
  2. Popover opens with AssistantNudges component
  3. Component fetches suggestions via React Query hooks
  4. Results displayed as interactive pills or generated prompts
  5. User can apply suggestions (adds component + creates edge) or replace prompts

Variable Management

  • All agentic variables now centralized in AGENTIC_VARIABLES constant
  • Type changed to CREDENTIAL_TYPE for security
  • Variables: FLOW_ID, OPENAI_API_KEY, USER_ID, COMPONENT_ID, FIELD_NAME, FLOW_DETAILS, COMPONENT_DETAILS, FIELD_VALUE, FIELD_DETAILS, VISUALISE_FLOW

⚠️ Breaking Changes

  • Agentic experience is now enabled by default - MCP server will start automatically
  • Router architecture changed - router_v1 now conditionally includes agentic router in main.py
  • Agentic variable type changed from GENERIC_TYPE to CREDENTIAL_TYPE

📊 Impact

  • 17 files changed across backend and frontend
  • Effort estimates: 7 High, 10 Medium complexity changes
  • Introduces new API surface area under /agentic
  • New React components and hooks in frontend
  • Configuration default change affects all new installations

This PR represents a significant step toward making Langflow more intelligent and user-friendly by providing AI-powered assistance during flow building.

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 6, 2026
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 7, 2026
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 7, 2026
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 7, 2026
testing to see if test failures are caused by importing router_v1 or our new router is casuing the issue
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 7, 2026
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants