feat: send codedagentsplayground agenthub-config for coded agents (llamaindex, openai-agents) - #372
feat: send codedagentsplayground agenthub-config for coded agents (llamaindex, openai-agents)#372al3xanndru wants to merge 1 commit into
Conversation
Make LlamaIndex and OpenAI-Agents coded agents meter their design-time LLM calls as CodedAgents.Playground, using the shared resolve_coded_agenthub_config() helper from uipath.platform (design-time -> "codedagentsplayground", deployed -> None). - uipath-openai-agents: UiPathChatOpenAI defaults agenthub_config via the helper when the caller does not pass one (existing _build_headers already emits it). - uipath-llamaindex: inject the x-uipath-agenthub-config header into the OpenAI, Bedrock, and Vertex LLM clients' request headers. Adds uipath-platform>=0.2.18 to both packages (the release that adds the helper) and tests. Bumps uipath-openai-agents 0.1.0 -> 0.1.1 and uipath-llamaindex 0.6.0 -> 0.6.1. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Aligns LlamaIndex and OpenAI-Agents coded-agent integrations with the LangGraph metering behavior by defaulting design-time LLM calls to the CodedAgents.Playground pool (via codedagentsplayground) and omitting the marker in deployed runs (falling back to AgentHub.LLM). This is done by wiring the shared resolve_coded_agenthub_config() helper into each package’s gateway header construction.
Changes:
uipath-openai-agents: defaultagenthub_configviaresolve_coded_agenthub_config()when not explicitly provided, relying on existing header emission.uipath-llamaindex: injectx-uipath-agenthub-config(viaHEADER_AGENTHUB_CONFIG) into OpenAI/Bedrock/Vertex gateway request headers.- Add
uipath-platform>=0.2.18,<0.3.0, bump package versions, and add tests for design-time vs deployed behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/uipath-openai-agents/src/uipath_openai_agents/chat/openai.py | Defaults agenthub_config using resolve_coded_agenthub_config() so header behavior matches metering requirements. |
| packages/uipath-openai-agents/tests/test_chat_openai.py | Adds tests validating config header presence/absence based on design-time vs deployed environment. |
| packages/uipath-openai-agents/pyproject.toml | Adds uipath-platform dependency and bumps version to 0.1.1. |
| packages/uipath-llamaindex/src/uipath_llamaindex/llms/_openai.py | Adds agenthub config header into OpenAI default headers via shared helper. |
| packages/uipath-llamaindex/src/uipath_llamaindex/llms/bedrock.py | Injects agenthub config header into Bedrock gateway request modification path. |
| packages/uipath-llamaindex/src/uipath_llamaindex/llms/vertex.py | Injects agenthub config header into Vertex gateway request rewrite transport. |
| packages/uipath-llamaindex/tests/llms/test_openai.py | Adds tests validating default headers include/omit agenthub config in design-time vs deployed. |
| packages/uipath-llamaindex/pyproject.toml | Adds uipath-platform dependency and bumps version to 0.6.1. |
Suppressed comments (2)
packages/uipath-openai-agents/tests/test_chat_openai.py:96
UiPathConfig.reset()cleanup is not guaranteed if the assertion fails; that can leak global config state into later tests. Wrap the test body in atry/finallyso the reset always runs.
monkeypatch.setenv("UIPATH_JOB_KEY", "deployed-job")
monkeypatch.chdir(tmp_path)
UiPathConfig.reset()
client = UiPathChatOpenAI(token="t", org_id="org", tenant_id="tn")
assert "X-UiPath-AgentHub-Config" not in client._build_headers()
UiPathConfig.reset()
packages/uipath-llamaindex/tests/llms/test_openai.py:100
UiPathConfig.reset()cleanup is not guaranteed if the assertion fails; that can leak global config state into later tests. Wrap the test body in atry/finallyso the reset always runs.
monkeypatch.setenv("UIPATH_URL", "https://cloud.uipath.com/org/tenant/")
monkeypatch.setenv("UIPATH_ACCESS_TOKEN", "token")
monkeypatch.setenv("UIPATH_JOB_KEY", "deployed-job")
monkeypatch.delenv("UIPATH_PROJECT_ID", raising=False)
monkeypatch.chdir(tmp_path)
UiPathConfig.reset()
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| monkeypatch.delenv("UIPATH_JOB_KEY", raising=False) | ||
| monkeypatch.chdir(tmp_path) | ||
| UiPathConfig.reset() | ||
|
|
||
| client = UiPathChatOpenAI(token="t", org_id="org", tenant_id="tn") | ||
| assert ( | ||
| client._build_headers()["X-UiPath-AgentHub-Config"] == "codedagentsplayground" | ||
| ) | ||
| UiPathConfig.reset() |
| monkeypatch.setenv("UIPATH_URL", "https://cloud.uipath.com/org/tenant/") | ||
| monkeypatch.setenv("UIPATH_ACCESS_TOKEN", "token") | ||
| monkeypatch.delenv("UIPATH_JOB_KEY", raising=False) | ||
| monkeypatch.delenv("UIPATH_PROJECT_ID", raising=False) | ||
| monkeypatch.chdir(tmp_path) | ||
| UiPathConfig.reset() | ||
|
|
||
| llm = UiPathOpenAI(model=OpenAIModel.GPT_4O_2024_08_06) | ||
| assert ( | ||
| llm.default_headers.get("x-uipath-agenthub-config") == "codedagentsplayground" | ||
| ) | ||
| UiPathConfig.reset() |
What
Makes LlamaIndex and OpenAI-Agents coded agents meter their design-time LLM calls as
CodedAgents.Playground(drawing that pool) and deployed runs asAgentHub.LLM— matching what the LangGraph path already does. Both sendx-uipath-agenthub-configvia the sharedresolve_coded_agenthub_config()helper fromuipath.platform(design-time →"codedagentsplayground", deployed →None).Neither package depends on
uipath-llm-client, so they don't inherit the LangGraph change — each builds its own gateway headers. This wires the shared helper into those header paths.Changes
uipath-openai-agents(chat/openai.py)UiPathChatOpenAIdefaultsagenthub_configvia the helper when the caller doesn't pass one; the existing_build_headers()already emits the header. Explicitagenthub_configstill wins.uipath-llamaindex(all three LLM providers)llms/_openai.py,llms/bedrock.py,llms/vertex.py: injectx-uipath-agenthub-configinto the request headers.Both
uipath-platform>=0.2.18(the release adding the helper)._build_headers; llamaindex_openaidefault headers) covering design-time → marker present, deployed → omitted.uipath-openai-agents 0.1.0→0.1.1,uipath-llamaindex 0.6.0→0.6.1.Requires
uipath-platform 0.2.18, introduced by uipath-python #1860. Until that publishes,uv synccan't resolve the pin, so CI is red and I couldn't run the suites locally — validate early via the repo'stest-core-dev-versionlabel against a dev build. Merge #1860 first.Notes
ruff check+ruff formatclean on all changed files.uipath-openai-agentsrepo is not touched — this targets the active monorepo home.Related: AgentHubService #1618 · gitops #551167 · uipath-llm-client #125 · langchain #1035
🤖 Generated with Claude Code