Skip to content

fix(cli): only claim uipath new scaffolds for langchain agents - #1069

Draft
vldcmp-uipath wants to merge 1 commit into
mainfrom
fix/gate-new-middleware-on-project-type
Draft

fix(cli): only claim uipath new scaffolds for langchain agents#1069
vldcmp-uipath wants to merge 1 commit into
mainfrom
fix/gate-new-middleware-on-project-type

Conversation

@vldcmp-uipath

@vldcmp-uipath vldcmp-uipath commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Important

Draft until UiPath/uipath-python#1886 is approved and uipath 2.14.15 is published. The middleware imports uipath._cli.models.project_types / uipath._cli.models.agent_frameworks, which only exist from 2.14.15. For dev-build validation and TestPyPI publishing, this PR temporarily pins uipath==2.14.15.dev1018867615 (the dev build of #1886) sourced from the testpypi index, with uv.lock resolved against it. Before marking ready for review: restore "uipath>=2.14.15, <2.15.0", drop the [tool.uv.sources] testpypi entry for uipath, and run uv lock.

Problem

langgraph_new_middleware returns should_continue=False unconditionally, so installing uipath-langchain hijacks uipath new process-wide and the base function scaffold becomes unreachable (UiPath/uipath-python#1543). This also breaks the uip function new -l py path, which delegates to uipath new and expects a function project.

Changes

  • The middleware now takes project_type / agent_framework (forwarded by uipath new since 2.14.15) and claims the command for --type auto (the default: an installed framework wins, preserving today's behaviour) and for --type agent with the langchain framework; everything else passes through to the base scaffold or another framework's integration.
  • Defaults (ProjectType.AGENT / AgentFramework.LANGCHAIN) preserve current behaviour when an older uipath CLI calls with just the project name.
  • Comparisons use != rather than identity so callers passing plain strings gate correctly (the enums subclass str).
  • Version bumped to 0.17.9; uipath floor raised to 2.14.15.

Behaviour with uipath >= 2.14.15

Command Result
uipath new my-fn (or --type auto) LangGraph agent project (auto default: installed framework claims it)
uipath new my-fn --type function function project (guaranteed — previously unreachable)
uipath new my-agent --type agent LangGraph agent project (unchanged)
uipath new x --type agent --agent-framework pydantic-ai passes through to that framework's integration

Testing

  • 9/9 in tests/cli/test_new.py (7 new cases incl. plain-string gating and old-CLI default), mypy and ruff clean, run against the TestPyPI dev build uipath==2.14.15.dev1018867615.
  • Verified end-to-end in a venv with both packages installed editable.

🤖 Generated with Claude Code

Development Package

  • Use uipath pack --nolock to get the latest dev build from this PR (requires version range).
  • Add this package as a dependency in your pyproject.toml:
[project]
dependencies = [
  # Exact version:
  "uipath-langchain==0.17.9.dev1010695775",

  # Any version from PR
  "uipath-langchain>=0.17.9.dev1010690000,<0.17.9.dev1010700000"
]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

[tool.uv.sources]
uipath-langchain = { index = "testpypi" }

[tool.uv]
override-dependencies = [
    "uipath-langchain>=0.17.9.dev1010690000,<0.17.9.dev1010700000",
]

The `new` middleware returned `should_continue=False` for every call, so
installing uipath-langchain made the base `uipath new` function scaffold
unreachable (UiPath/uipath-python#1543).

It now claims a scaffold only when the base CLI asks for one it can
serve: `--type auto` (where a single installed integration is meant to
win) or `--type agent --agent-framework langchain`. Every other case —
`--type function`, or an agent scaffold for another framework — passes
through to the next middleware.

The gate compares with `==` rather than `is`, so callers passing plain
strings (an older uipath, or a direct middleware call) still work.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@vldcmp-uipath
vldcmp-uipath force-pushed the fix/gate-new-middleware-on-project-type branch from eba8fe7 to e8f33bd Compare September 11, 2026 12:49
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant