-
Notifications
You must be signed in to change notification settings - Fork 34
feat: support coded DeepAgents runtime workspaces #991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andreitava-uip
wants to merge
1
commit into
main
Choose a base branch
from
feat/coded-deepagents-runtime
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "dependencies": ["."], | ||
| "graphs": { | ||
| "agent": "./graph.py:graph" | ||
| }, | ||
| "env": ".env" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "runtimeOptions": { | ||
| "isConversational": false | ||
| }, | ||
| "id": "be591088-69a1-4cb7-b472-32ad7acd3735" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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." | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "dependencies": ["."], | ||
| "graphs": { | ||
| "agent": "./graph.py:graph" | ||
| }, | ||
| "env": ".env" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| ] | ||
|
|
||
| [dependency-groups] | ||
| dev = [ | ||
| "uipath-dev", | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "runtimeOptions": { | ||
| "isConversational": false | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}") |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.