Skip to content

feat: Governance runtime implementation#899

Open
viswa-uipath wants to merge 1 commit into
mainfrom
feat/governance
Open

feat: Governance runtime implementation#899
viswa-uipath wants to merge 1 commit into
mainfrom
feat/governance

Conversation

@viswa-uipath

@viswa-uipath viswa-uipath commented Jun 9, 2026

Copy link
Copy Markdown

TEST IN PROGRESS: Changes for lang-chain adapter to support governance

Development Package

  • Use uipath pack --nolock to get the latest dev build from this PR (requires version range).
  • Add this package as a dependency in your pyproject.toml:
[project]
dependencies = [
  # Exact version:
  "uipath-langchain==0.11.17.dev1008994879",

  # Any version from PR
  "uipath-langchain>=0.11.17.dev1008990000,<0.11.17.dev1009000000"
]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

[tool.uv.sources]
uipath-langchain = { index = "testpypi" }

[tool.uv]
override-dependencies = [
    "uipath-langchain>=0.11.17.dev1008990000,<0.11.17.dev1009000000",
]

Copilot AI review requested due to automatic review settings June 9, 2026 13:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a LangChain/LangGraph governance integration layer to uipath-langchain, wiring UiPath’s governance evaluator into LangChain callbacks and exposing registration via an entry point so uipath-runtime can discover the adapter.

Changes:

  • Introduces a LangChainAdapter + governed proxy wrapper and a callback handler that calls EvaluatorProtocol hooks for model/tool events.
  • Adds governance adapter registration (uipath.governance.adapters entry point) with import-time idempotent self-registration.
  • Updates dependency/lock configuration to pull in updated uipath-core and a dev/test build of uipath-runtime (currently with non-portable lockfile sources).

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 9 comments.

File Description
src/uipath_langchain/governance/adapter.py Implements the LangChain/LangGraph adapter, wrapper, and callback handler that triggers governance evaluations.
src/uipath_langchain/governance/__init__.py Registers the governance adapter on import and exposes an entry-point registration function.
pyproject.toml Adds governance adapter entry point; bumps uipath-core; pins uipath-runtime to a dev build and adds a uv TestPyPI source override.
uv.lock Updates locked dependencies, but currently includes a machine-local Windows editable uipath-runtime source.

Comment thread src/uipath_langchain/governance/adapter.py Outdated
Comment thread src/uipath_langchain/governance/adapter.py
Comment thread src/uipath_langchain/governance/adapter.py
Comment thread src/uipath_langchain/governance/adapter.py
Comment thread src/uipath_langchain/governance/adapter.py Outdated
Comment thread src/uipath_langchain/governance/adapter.py
Comment thread src/uipath_langchain/governance/adapter.py
Comment thread pyproject.toml
Comment on lines 8 to 13
"uipath>=2.10.79, <2.11.0",
"uipath-core>=0.5.17, <0.6.0",
"uipath-core>=0.5.18, <0.6.0",
"uipath-platform>=0.1.61, <0.2.0",
"uipath-runtime>=0.11.0, <0.12.0",
"uipath-runtime==0.11.0.dev1001180441",
"langgraph>=1.1.8, <2.0.0",
"langchain-core>=1.2.11, <2.0.0",
Comment thread pyproject.toml
Comment on lines +161 to +163
[tool.uv.sources]
uipath-runtime = { index = "testpypi" }

@sonarqubecloud

Copy link
Copy Markdown

Registers a LangChain/LangGraph adapter with the uipath-core adapter
registry so GovernanceRuntime can attach BEFORE_MODEL / AFTER_MODEL /
TOOL_CALL / AFTER_TOOL hooks via LangChain's callback system. Exposed
as a uipath.governance.adapters entry point and self-registers on
import. Bumps uipath-core to 0.6.x and uipath-runtime to 0.11.x to
pick up the new adapter contracts.

Key behaviour:
- BEFORE_MODEL is scoped to the latest message only. Earlier passes
  concatenated the entire prompt history, which re-fired violations
  from older turns on every subsequent LLM call. The callback now
  takes the last entry of the last batched prompt (mirrors the
  BEFORE_AGENT latest_only contract in uipath-runtime).
- List-of-blocks content (multimodal, OpenAI function-call, Anthropic
  tool_use, Claude extended thinking) is walked via _extract_block_text
  instead of str(msg.content), so structured shapes produce clean text
  with no dict-repr noise that breaks regex/field rules.
- Both on_chat_model_start and on_llm_start cap extracted input at
  _BEFORE_MODEL_TEXT_CAP = 64000 (matches the runtime side).
- register_governance_adapter is idempotent — uses the AdapterRegistry
  instance state as the single source of truth (no module-level flag).

Packaging:
- prerelease = "allow" plus override-dependencies for uipath-runtime
  under [tool.uv] so the dev pin can satisfy the umbrella's stable-only
  constraint. Re-locked so uipath-runtime resolves from testpypi rather
  than the local editable Windows path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants