Skip to content

Commit 8d97e34

Browse files
committed
fix: clear agenthub_config via field_validator so headers are correct
1 parent cf3ffcb commit 8d97e34

4 files changed

Lines changed: 29 additions & 12 deletions

File tree

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.10.17"
3+
version = "0.10.18"
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"
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import os
22

3-
from pydantic import model_validator
3+
from pydantic import field_validator
44

55

66
class _AgentHubConfigDefaultMixin:
7-
@model_validator(mode="after")
8-
def _clear_agenthub_config_default(self):
9-
if os.getenv("UIPATH_AGENTHUB_CONFIG") is None:
10-
client_settings = getattr(self, "client_settings", None)
11-
if client_settings is not None and hasattr(
12-
client_settings, "agenthub_config"
13-
):
14-
client_settings.agenthub_config = None
15-
return self
7+
@field_validator("client_settings", mode="after")
8+
@classmethod
9+
def _clear_agenthub_config_default(cls, client_settings):
10+
if (
11+
client_settings is not None
12+
and os.getenv("UIPATH_AGENTHUB_CONFIG") is None
13+
and hasattr(client_settings, "agenthub_config")
14+
):
15+
client_settings.agenthub_config = None
16+
return client_settings

tests/chat/test_agenthub_config_default.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ def test_env_var_is_honored(self, cls, monkeypatch):
6363
llm = cls()
6464
assert llm.client_settings.agenthub_config == "agentsplayground"
6565

66+
def test_no_agenthub_header_on_inner_http_client(self, cls):
67+
llm = cls()
68+
client = getattr(llm, "uipath_sync_client", None)
69+
if client is None:
70+
pytest.skip(f"{cls.__name__} has no uipath_sync_client to inspect")
71+
assert "x-uipath-agenthub-config" not in {key.lower() for key in client.headers}
72+
73+
def test_env_var_is_honored_on_inner_http_client(self, cls, monkeypatch):
74+
monkeypatch.setenv("UIPATH_AGENTHUB_CONFIG", "agentsplayground")
75+
llm = cls()
76+
client = getattr(llm, "uipath_sync_client", None)
77+
if client is None:
78+
pytest.skip(f"{cls.__name__} has no uipath_sync_client to inspect")
79+
normalized = {key.lower(): value for key, value in client.headers.items()}
80+
assert normalized.get("x-uipath-agenthub-config") == "agentsplayground"
81+
6682

6783
_UPSTREAM_CASES = [
6884
"uipath_langchain_client.clients.normalized.chat_models:UiPathChat",

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)