Skip to content

Commit 30186ab

Browse files
feat: pass x-uipath-licensing-context header on LLM Gateway calls
Reads licensing context from UiPathConfig (uipath.json) and includes it in build_uipath_headers so chat model HTTP calls carry the header. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2126bba commit 30186ab

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-langchain"
3-
version = "0.8.6"
3+
version = "0.8.7"
44
description = "Python SDK that enables developers to build and deploy LangGraph agents to the UiPath Cloud Platform"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

src/uipath_langchain/chat/http_client/headers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
from urllib.parse import quote
55

6+
from uipath.platform.common._config import UiPathConfig
67
from uipath.platform.common.constants import (
78
ENV_FOLDER_KEY,
89
ENV_JOB_KEY,
@@ -15,6 +16,7 @@
1516
HEADER_INTERNAL_ACCOUNT_ID,
1617
HEADER_INTERNAL_TENANT_ID,
1718
HEADER_JOB_KEY,
19+
HEADER_LICENSING_CONTEXT,
1820
HEADER_LLMGATEWAY_BYO_CONNECTION_ID,
1921
HEADER_PROCESS_KEY,
2022
HEADER_TRACE_ID,
@@ -53,9 +55,13 @@ def build_uipath_headers(
5355
headers[HEADER_FOLDER_KEY] = folder_key
5456
if trace_id := os.getenv(ENV_UIPATH_TRACE_ID):
5557
headers[HEADER_TRACE_ID] = trace_id
58+
if licensing_context := UiPathConfig.licensing_context:
59+
headers[HEADER_LICENSING_CONTEXT] = licensing_context
60+
5661
if inject_routing:
5762
if tenant_id := os.getenv(ENV_TENANT_ID):
5863
headers[HEADER_INTERNAL_TENANT_ID] = tenant_id
5964
if organization_id := os.getenv(ENV_ORGANIZATION_ID):
6065
headers[HEADER_INTERNAL_ACCOUNT_ID] = organization_id
66+
6167
return headers

tests/chat/test_context_headers.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from unittest.mock import patch
2+
from unittest.mock import PropertyMock, patch
33

44
from uipath_langchain.chat.http_client import build_uipath_headers
55

@@ -49,3 +49,27 @@ def test_optional_gateway_headers(self) -> None:
4949
)
5050
assert headers["x-uipath-agenthub-config"] == "config-abc"
5151
assert headers["x-uipath-llmgateway-byoisconnectionid"] == "conn-xyz"
52+
53+
def test_licensing_context_header_present(self) -> None:
54+
with (
55+
patch.dict(os.environ, {}, clear=True),
56+
patch(
57+
"uipath.platform.common._config.ConfigurationManager.licensing_context",
58+
new_callable=PropertyMock,
59+
return_value="robot:unattended",
60+
),
61+
):
62+
headers = build_uipath_headers()
63+
assert headers["x-uipath-licensing-context"] == "robot:unattended"
64+
65+
def test_licensing_context_header_absent_when_none(self) -> None:
66+
with (
67+
patch.dict(os.environ, {}, clear=True),
68+
patch(
69+
"uipath.platform.common._config.ConfigurationManager.licensing_context",
70+
new_callable=PropertyMock,
71+
return_value=None,
72+
),
73+
):
74+
headers = build_uipath_headers()
75+
assert "x-uipath-licensing-context" not in headers

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)