Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = "uipath-langchain"
version = "0.14.15"
version = "0.15.0"
description = "Python SDK that enables developers to build and deploy LangGraph agents to the UiPath Cloud Platform"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
dependencies = [
"uipath>=2.13.7, <2.14.0",
"uipath-core>=0.5.29, <0.6.0",
"uipath-platform>=0.2.12, <0.3.0",
"uipath-platform>=0.2.13, <0.3.0",
"uipath-runtime>=0.12.5, <0.13.0",
"uipath-llm-client>=1.17.1, <1.18.0",
"langgraph>=1.1.8, <2.0.0",
Expand Down
7 changes: 7 additions & 0 deletions samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This sample demonstrates a simple LangGraph agent that performs basic arithmetic
## [Chat agent](chat-agent)
This sample shows how to build an AI assistant using LangGraph and Tavily search for movie research and recommendations.

## [Coded DeepAgent](coded-deepagent)
This sample demonstrates a task-mode coded DeepAgent using the UiPath runtime workspace contract, structured output, a tool, and a review subagent.

## [Company research agent](company-research-agent)
This sample demonstrates how to create an agent that researches companies and develops outreach strategies using web search capabilities.

Expand Down Expand Up @@ -44,3 +47,7 @@ This sample demonstrates automatic classification of support tickets into catego

## [Wait until timeout agent](wait-until-timeout-agent)
This sample demonstrates waiting for whichever happens first: a child UiPath process completes, or a timer expires.
## [Coded DeepAgent Node](coded-deepagent-node)

[`coded-deepagent-node`](coded-deepagent-node/) demonstrates a parent LangGraph
workflow that passes a structured request to an embedded coded DeepAgent node.
40 changes: 40 additions & 0 deletions samples/coded-deepagent-node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Coded DeepAgent Node

This sample embeds a coded DeepAgent as one node in a larger LangGraph workflow.
The parent graph accepts a structured `request`, converts it to a human message,
then delegates launch planning to the agent node.

The compiled parent graph is explicitly marked with
`with_uipath_managed_workspace`. This declares the requirement at the runtime
entrypoint, so it remains reliable when the agent node is wrapped in other
LangChain runnables.

## Requirements

- Python 3.11+
- UiPath runtime credentials for `UiPathAzureChatOpenAI`
- Access to the configured OpenAI model, `gpt-5.4`

## Installation

```bash
cd samples/coded-deepagent-node
uv sync
uv run uipath auth
```

Managed workspace hydration is opt-in. Enable it before running this sample:

```bash
export UIPATH_FEATURE_DeepAgentsWorkspaceHydration=true
```

## Usage

```bash
uv run uipath init
uv run uipath run agent "$(cat input.json)"
```

The planner writes `/launch/plan.md` to its managed workspace before returning
the plan to the parent workflow.
83 changes: 83 additions & 0 deletions samples/coded-deepagent-node/graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"""Parent LangGraph workflow with an embedded UiPath DeepAgent node."""

from typing import Annotated

from langchain_core.messages import AnyMessage, HumanMessage
from langchain_core.tools import tool
from langgraph.graph import END, START, StateGraph
from langgraph.graph.message import add_messages
from typing_extensions import TypedDict

from uipath_langchain.chat import UiPathAzureChatOpenAI
from uipath_langchain.deepagents import (
create_uipath_deep_agent,
with_uipath_managed_workspace,
)


class LaunchRequest(TypedDict):
"""Structured input accepted by the parent workflow."""

request: str


class LaunchWorkflowState(LaunchRequest):
"""State owned by the parent workflow around the planner node."""

messages: Annotated[list[AnyMessage], add_messages]
preflight_complete: bool
workflow_complete: bool


@tool
def score_launch_readiness(audience: str, constraints: list[str]) -> str:
"""Return a deterministic launch-readiness score for a target audience."""
score = 80
if len(constraints) >= 3:
score -= 10
if any("compliance" in item.lower() for item in constraints):
score -= 10
if any("deadline" in item.lower() for item in constraints):
score -= 5
return f"Launch readiness for {audience}: {max(score, 35)}/100"


MODEL = UiPathAzureChatOpenAI(model="gpt-5.4", temperature=0)

PLANNER_PROMPT = """You are the launch-planning node in a larger workflow.

Use score_launch_readiness to assess the requested launch. Use the provided
filesystem tools to write /launch/plan.md before giving a concise plan with the
readiness assessment, milestones, risks, and owners.
"""

launch_planner = create_uipath_deep_agent(
model=MODEL,
system_prompt=PLANNER_PROMPT,
tools=[score_launch_readiness],
)


def preflight(state: LaunchWorkflowState) -> dict[str, bool | list[HumanMessage]]:
"""Adapt the structured request before delegating to the planner node."""
return {
"preflight_complete": True,
"messages": [HumanMessage(content=state["request"])],
}


def complete(_: LaunchWorkflowState) -> dict[str, bool]:
"""Record that the parent workflow has completed the planner stage."""
return {"workflow_complete": True}


builder = StateGraph(LaunchWorkflowState, input_schema=LaunchRequest)
builder.add_node("preflight", preflight)
builder.add_node("launch_planner", launch_planner)
builder.add_node("complete", complete)
builder.add_edge(START, "preflight")
builder.add_edge("preflight", "launch_planner")
builder.add_edge("launch_planner", "complete")
builder.add_edge("complete", END)

graph = with_uipath_managed_workspace(builder.compile())
3 changes: 3 additions & 0 deletions samples/coded-deepagent-node/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"request": "Create a six-week pilot launch plan for an Invoice Exception Copilot used by accounts payable managers at three enterprise customers. Security review must complete before the external rollout, and the support team needs enablement material."
}
7 changes: 7 additions & 0 deletions samples/coded-deepagent-node/langgraph.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": ["."],
"graphs": {
"agent": "./graph.py:graph"
},
"env": ".env"
}
17 changes: 17 additions & 0 deletions samples/coded-deepagent-node/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[project]
name = "coded-deepagent-node"
version = "0.0.1"
description = "Parent LangGraph workflow with an embedded UiPath DeepAgent node"
authors = [{ name = "UiPath", email = "support@uipath.com" }]
requires-python = ">=3.11"
dependencies = [
"uipath-langchain>=0.15.0, <0.16.0",
]

[tool.uv.sources]
uipath-langchain = { path = "../..", editable = true }

[dependency-groups]
dev = [
"uipath-dev",
]
6 changes: 6 additions & 0 deletions samples/coded-deepagent-node/uipath.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"runtimeOptions": {
"isConversational": false
},
"id": "be591088-69a1-4cb7-b472-32ad7acd3735"
}
53 changes: 53 additions & 0 deletions samples/coded-deepagent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Coded DeepAgent

This sample demonstrates a task-mode coded agent built with
`uipath_langchain.deepagents.create_uipath_deep_agent`.

UiPath owns the filesystem backend and checkpointer configuration. The graph
declares a managed-workspace runtime requirement, which the UiPath runtime can
satisfy with a disk-backed workspace hydrated through job attachments.

## What It Shows

- Standard DeepAgents message input and structured output.
- A standard LangChain tool used by the main DeepAgent.
- A DeepAgents subagent used for risk review.
- Runtime-provided, attachment-hydrated filesystem workspace.

## Files

- `graph.py`: task-mode coded DeepAgent graph.
- `input.json`: sample input payload.
- `langgraph.json`: LangGraph entrypoint.
- `uipath.json`: UiPath task-mode runtime configuration.
- `pyproject.toml`: sample dependencies.
- `agent.mermaid`: conceptual view of the agent workflow.

## Requirements

- UiPath runtime credentials for `UiPathAzureChatOpenAI`.
- Access to the configured model, `gpt-5.4`.

## Installation

```bash
cd samples/coded-deepagent
uv sync
uv run uipath auth
```

Managed workspace hydration is opt-in. Enable it before running this sample:

```bash
export UIPATH_FEATURE_DeepAgentsWorkspaceHydration=true
```

## Usage

```bash
uv run uipath init
uv run uipath run agent "$(cat input.json)"
```

The agent uses the filesystem tools supplied by the DeepAgents harness for its
working files and returns a structured launch brief.
15 changes: 15 additions & 0 deletions samples/coded-deepagent/agent.mermaid
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
flowchart TB
__start__(__start__)
deep_agent(deep_agent)
tools([agent tools])
risk_reviewer([risk_reviewer subagent])
workspace[(runtime workspace)]
structured_output(structured output)
__end__(__end__)

__start__ --> deep_agent
deep_agent <--> tools
deep_agent -. delegates review .-> risk_reviewer
deep_agent -. writes files .-> workspace
deep_agent --> structured_output
structured_output --> __end__
66 changes: 66 additions & 0 deletions samples/coded-deepagent/graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""Task-mode coded DeepAgent using the UiPath DeepAgents API."""

from langchain_core.tools import tool
from pydantic import BaseModel

from uipath_langchain.chat import UiPathAzureChatOpenAI
from uipath_langchain.deepagents import create_uipath_deep_agent


class BriefOutput(BaseModel):
"""Structured launch brief returned by the agent."""

executive_summary: str
launch_plan: list[str]
risk_review: list[str]


@tool
def score_launch_readiness(audience: str, constraints: list[str]) -> str:
"""Score launch readiness from simple deterministic planning signals."""
score = 80
if len(constraints) >= 3:
score -= 10
if any("compliance" in item.lower() for item in constraints):
score -= 10
if any("deadline" in item.lower() for item in constraints):
score -= 5
return f"Launch readiness for {audience}: {max(score, 35)}/100"


MODEL = UiPathAzureChatOpenAI(model="gpt-5.4", temperature=0)

RISK_REVIEWER_PROMPT = """You are a launch risk reviewer.
Review the proposed launch plan for practical delivery risks, compliance gaps,
unclear ownership, and missing follow-up work. Return concise findings that the
main agent can incorporate into the final brief."""

RISK_REVIEWER = {
"name": "risk_reviewer",
"description": "Reviews launch plans for execution risks and missing safeguards.",
"system_prompt": RISK_REVIEWER_PROMPT,
"model": MODEL,
}


SYSTEM_PROMPT = """You are a product launch planning agent.

Use the available planning tools. Use score_launch_readiness to get
a deterministic readiness signal. Delegate a plan review to risk_reviewer before
finalizing the answer.

Use the provided filesystem tools to write these working files before producing the
final answer:
- /launch/brief.md with the final launch brief
- /launch/risks.md with the risk review

Return structured output matching the schema."""


graph = create_uipath_deep_agent(
model=MODEL,
system_prompt=SYSTEM_PROMPT,
response_format=BriefOutput,
tools=[score_launch_readiness],
subagents=[RISK_REVIEWER],
)
8 changes: 8 additions & 0 deletions samples/coded-deepagent/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"messages": [
{
"type": "human",
"content": "Create a pilot launch plan for Invoice Exception Copilot for accounts payable operations managers at three enterprise customers. The security review must complete before external rollout, the deadline is six weeks away, and the support team needs enablement material."
}
]
}
7 changes: 7 additions & 0 deletions samples/coded-deepagent/langgraph.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": ["."],
"graphs": {
"agent": "./graph.py:graph"
},
"env": ".env"
}
14 changes: 14 additions & 0 deletions samples/coded-deepagent/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[project]
name = "coded-deepagent"
version = "0.0.1"
description = "Task-mode coded DeepAgent using the UiPath runtime workspace contract"
authors = [{ name = "UiPath", email = "support@uipath.com" }]
requires-python = ">=3.11"
dependencies = [
"uipath-langchain>=0.15.0, <0.16.0",
]
Comment thread
andreitava-uip marked this conversation as resolved.

[dependency-groups]
dev = [
"uipath-dev",
]
5 changes: 5 additions & 0 deletions samples/coded-deepagent/uipath.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"runtimeOptions": {
"isConversational": false
}
}
17 changes: 17 additions & 0 deletions src/uipath_langchain/deepagents/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""UiPath DeepAgents integration."""

from typing import Any

__all__ = ["create_uipath_deep_agent", "with_uipath_managed_workspace"]


def __getattr__(name: str) -> Any:
if name == "create_uipath_deep_agent":
from .agent import create_uipath_deep_agent

return create_uipath_deep_agent
if name == "with_uipath_managed_workspace":
from .metadata import with_uipath_managed_workspace

return with_uipath_managed_workspace
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
Loading
Loading