Failed to prepare environment for coded agent?

I’m trying to run a UiPath LangChain Agent, following the quickstart guide for setting up the project and publishing to Automation Cloud.

The agent runs fine locally, on my own machine. But whenever I try to run it from Orchestrator I get the error below:

{"Code":"Serverless.PythonCodedAgent.PrepareEnvironmentError","Title":"Failed to prepare environment","Detail":"An error occurred while installing the package dependencies. Please try again. If the error persists, please contact support.","Category":"System","Status":null}

The below picture shows the setup of the agent in Orchestrator when I start a job:

I’ve checked my licenses, and I have a few Robot Units and Agent Units left, so I don’t think this is a licensing issue.

Since this is an experiment on my community cloud tenant, I don’t think going to UiPath support is an option as noted in the error.

So on to the question, what am I doing wrong here?

Side question:
Can coded agents only run on Cloud Robot - Serverless robots? I’ve been able to run agents built in agents builder/Studio Web on regular unattended and non-production unattended robots, but I don’t even seem to get the option to assign coded agents to machines connected to my machine templates?

@manderss

Your environment configuration is missing url tenant etc fields which are needed.may be the in quickstart they are not provided

Cheers

1 Like

Yeah, I don’t think those are mentioned anywhere in the quickstart. So if I want to list the required environment variables, it should be something along these lines?

  • UiPath_URL https://cloud.uipath.com/org/tenant
  • OPENAI_API_KEY - Or it can be retrieved from Assets when not provided from environment as in the video.

Followup question on Open AI key and licensing: Can coded agents consume LLM calls through whatever means are used from the UiPath platform and/or Generative AI activities, so that it would use whatever license units we have in UiPath? Or are we exclusively tied to providing our own external API key for coded agents?

(Will watch the video more thoroughly later, just putting this in writing for me to experiment with later and get it pointed out to me where I’m missing things :wink: )

@manderss

Yes the environment variables are on the same lines you are correct..reviewing the video fully can help to know all as you have already started doing it

For coded as it is your own agent its your own key

Cheers

1 Like

Aha, that’s a shame. Feels like there should be a tighter integration with the platform here , both in terms of being able to utilize existing AI licenses within it, and requiring me to add UiPath_URL manually for something running in the platform. But good to know, will experiment with it later!

On another note, I was experimenting with deploying agents through GitHub Actions to Orchestrator. And got it working with updating the project version to match the repositorys latest release tag, packing the project, deploying to Orchestrator up to the point I reached when creating the topic.

So what I’m missing in my pipeline is environment configuration, which would need another step for creating a .env file, inserting UiPath_URL and OPENAI_API_KEY. I feel like inserting secrets into a file like this, into a .nupkg file that is uploaded to artifacts for a later job to deploy is unsafe. So I’ll definitely explore using assets for the API key instead.

1 Like

Added “.env” creation in my pipeline now to get the UiPath_URL environment set. But it does not seem to do anything with the environment setup in Orchestrator.

Sure, it’s an easy to thing to do myself manually, but I’d rather not have to do that when I have automated deployments covering everything else.

I also tried adding both UiPath_URL and OPENAI_API_KEY manually now, still getting the same error.


I finally got this up and running after reporting this issue on the UiPath-langchain-python repository.

Turns out I needed to update with the following:

pyproject.toml updates

I was setting an invalid property on the version attribute of my toml file through my pipeline:

[project]
name = "my-agent"
version = "2.5.1-pr-64-dd44293"
description = "my-agent"
authors = [{ name = "John Doe", email = "john.doe@myemail.com" }]
dependencies = [
    "uipath-langchain>=0.0.106",
]
requires-python = ">=3.10"

[tool.setuptools]
py-modules = []

I needed to update my pipeline to standards for setting pre-release versions. Along with this I had to configure the setup tools, as done in the last line of the toml contents above.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.