Skip to content

feat(cli): add --type flag to uipath new to support function project scaffolding alongside agents #1543

@AlexBizon

Description

@AlexBizon

Problem

When uipath-langchain is installed alongside uipath, running uipath new <name> always creates a LangGraph agent project regardless of what the user intended. This happens because langgraph_new_middleware in uipath-langchain intercepts the new command unconditionally and returns should_continue=False, completely bypassing the base function scaffolding logic.

# uipath_langchain/_cli/cli_new.py
def langgraph_new_middleware(name: str) -> MiddlewareResult:
    # always runs, no way to opt out
    with console.spinner(f"Creating new agent {name} in current directory ..."):
        generate_script(directory)   # creates langgraph.json + agent main.py
        generate_pyproject(directory, name)  # uipath-langchain dep
    return MiddlewareResult(should_continue=False)  # base logic never runs

There is no way today to scaffold a pure Python function project (the EchoIn/EchoOut dataclass pattern from the base template) when uipath-langchain is installed.

Context

The uip CLI (UiPath/cli) has a functions-tool plugin that routes uip functions new --language py to uipath new <name>. Since functions-tool is explicitly for Functions (not agents), it always expects a function project to be scaffolded. With uipath-langchain installed the passthrough silently creates an agent project instead.

Proposed solution

1. Add --type option to uipath new in the base package (packages/uipath/src/uipath/_cli/cli_new.py):

@click.command()
@click.argument("name", type=str, default="")
@click.option(
    "--type",
    "project_type",
    type=click.Choice(["function", "agent"]),
    default="function",
    help="Project type to scaffold: function (default) or agent.",
)
@track_command("new")
def new(name: str, project_type: str):
    ...
    result = Middlewares.next("new", name, project_type=project_type)

2. Update langgraph_new_middleware in uipath-langchain to respect the flag:

def langgraph_new_middleware(name: str, project_type: str = "agent") -> MiddlewareResult:
    if project_type == "function":
        return MiddlewareResult(should_continue=True)  # pass through to base logic
    # existing agent scaffolding unchanged ...

Expected behaviour after fix

Command Result
uipath new my-fn function project (base template — default)
uipath new my-fn --type function function project (explicit)
uipath new my-agent --type agent LangGraph agent project (existing behaviour)

Why default to function

The base uipath package is language-agnostic and its own new command already creates a function project (the EchoIn/EchoOut template). The agent scaffolding lives in uipath-langchain as an opt-in extension. Defaulting to function preserves the base package's intent; users who want an agent project pass --type agent (or install uipath-langchain and rely on a future uipath new --type agent alias).

Files to change

  • packages/uipath/src/uipath/_cli/cli_new.py — add --type Click option, pass to middleware
  • uipath-langchain-python/src/uipath_langchain/_cli/cli_new.pylanggraph_new_middleware accepts and respects project_type

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions