Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/uipath-platform/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-platform"
version = "0.2.18"
version = "0.2.19"
description = "HTTP client library for programmatic access to UiPath Platform"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
ResourceOverwritesContext,
resource_override,
)
from ._config import UiPathApiConfig, UiPathConfig
from ._config import UiPathApiConfig, UiPathConfig, resolve_coded_agenthub_config
from ._endpoints_manager import EndpointManager
from ._execution_context import ExecutionSourceContext, UiPathExecutionContext
from ._folder_context import FolderContext, header_folder
Expand Down Expand Up @@ -86,6 +86,7 @@
"FolderContext",
"TokenData",
"UiPathConfig",
"resolve_coded_agenthub_config",
"CreateTask",
"CreateEscalation",
"WaitEscalation",
Expand Down
19 changes: 19 additions & 0 deletions packages/uipath-platform/src/uipath/platform/common/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,22 @@ def _internal_arguments(self) -> dict[str, Any] | None:


UiPathConfig = ConfigurationManager()


def resolve_coded_agenthub_config() -> str | None:
"""AgentHub config header value for a coded-agent run, or ``None`` when deployed.

Design-time runs — local, Studio Web, or a debug session — return
``codedagentsplayground`` so the agent's LLM calls draw the CodedAgents.Playground
licensing pool. A deployed run — a real Orchestrator job that is neither a Studio
Web project nor rooted to a debug session — returns ``None``, which the LLM gateway
resolves to the ``AgentHub.LLM`` operation code.
"""
from uipath.platform.constants import AGENTHUB_CONFIG_CODED_AGENTS_PLAYGROUND

deployed = (
bool(UiPathConfig.job_key)
and not UiPathConfig.is_studio_project
and not UiPathConfig.is_rooted_to_debug_job

@radu-mocanu radu-mocanu Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we exclude is_rooted_to_debug_job? are those not considered playground runs as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all these 3 conditions are true then it is an execution of a deployed agent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is considered playground if it is not deployed

)
return None if deployed else AGENTHUB_CONFIG_CODED_AGENTS_PLAYGROUND
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
HEADER_PROCESS_KEY = "x-uipath-processkey"
HEADER_TRACE_ID = "x-uipath-traceid"
HEADER_AGENTHUB_CONFIG = "x-uipath-agenthub-config"
AGENTHUB_CONFIG_CODED_AGENTS_PLAYGROUND = "codedagentsplayground"
HEADER_GUARDRAILS_SOURCE = "x-uipath-guardrails-source"
HEADER_LLMGATEWAY_BYO_CONNECTION_ID = "x-uipath-llmgateway-byoisconnectionid"
HEADER_SW_LOCK_KEY = "x-uipath-sw-lockkey"
Expand Down
47 changes: 46 additions & 1 deletion packages/uipath-platform/tests/common/test_config_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

import pytest

from uipath.platform.common._config import UiPathConfig
from uipath.platform.common._config import (
UiPathConfig,
resolve_coded_agenthub_config,
)
from uipath.platform.constants import (
AGENTHUB_CONFIG_CODED_AGENTS_PLAYGROUND,
ENTRY_POINTS_FILE,
ENV_BASE_URL,
ENV_FOLDER_KEY,
Expand Down Expand Up @@ -190,3 +194,44 @@ def test_has_eval_folder(self, monkeypatch, tmp_path):
assert UiPathConfig.has_eval_folder is False
(tmp_path / EVALS_FOLDER).mkdir()
assert UiPathConfig.has_eval_folder is True


class TestResolveCodedAgentHubConfig:
@pytest.fixture(autouse=True)
def _isolated_config(self, monkeypatch, tmp_path):
# Run in an empty dir so is_rooted_to_debug_job has no stray uipath.json,
# and reset the cached internal arguments around each case.
monkeypatch.chdir(tmp_path)
UiPathConfig.reset()
yield
UiPathConfig.reset()

def test_local_run_is_design_time(self):
# No job key -> local/design-time -> coded playground marker.
assert (
resolve_coded_agenthub_config() == AGENTHUB_CONFIG_CODED_AGENTS_PLAYGROUND
)

def test_deployed_job_returns_none(self, monkeypatch):
# Real job, not a studio project, not a debug session -> None (AgentHub.LLM).
monkeypatch.setenv(ENV_JOB_KEY, "deployed-job")
assert resolve_coded_agenthub_config() is None

def test_studio_web_job_is_design_time(self, monkeypatch):
# Job present but a studio project -> design-time.
monkeypatch.setenv(ENV_JOB_KEY, "sw-job")
monkeypatch.setenv(ENV_UIPATH_PROJECT_ID, "project-id")
assert (
resolve_coded_agenthub_config() == AGENTHUB_CONFIG_CODED_AGENTS_PLAYGROUND
)

def test_debug_rooted_job_is_design_time(self, monkeypatch, tmp_path):
# Job present, no studio project, but rooted to a debug session -> design-time.
monkeypatch.setenv(ENV_JOB_KEY, "debug-job")
(tmp_path / "uipath.json").write_text(
'{"runtime": {"internalArguments": {"isDebug": true}}}'
)
UiPathConfig.reset()
assert (
resolve_coded_agenthub_config() == AGENTHUB_CONFIG_CODED_AGENTS_PLAYGROUND
)
2 changes: 1 addition & 1 deletion packages/uipath-platform/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/uipath/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading