Repository navigation
feat(guardrails): let the runtime choose where guardrail check containers go - #1267
daniel-joica wants to merge 1 commit into
Conversation
…ners go Add a registrable parent resolver so a runtime can place guardrail check containers under the right model or tool call span, including parallel tool calls and resumed runs. Tool-scope stages now pass the tool name and call id. Coded agents are unchanged unless a resolver is registered. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Already-closed guardrail containers remain in deferred tracking, allowing later flushes or shutdown to end their spans again and trigger SDK warnings.
1 open issue
What changed in this PR
Adds runtime-controlled placement of middleware guardrail trace containers, preserving default placement when no resolver is registered.
Changes:
- Adds parent resolution and deferred-container closing APIs.
- Passes tool names and call IDs to guardrail stages.
- Adds resolver tests and bumps the version to 0.21.12.
| File | Description |
|---|---|
uv.lock |
Updates the locked package version. |
tests/guardrails/middlewares/test_grouping.py |
Tests resolved placement, fallback, and deferred closure. |
src/uipath_langchain/guardrails/middlewares/_grouping.py |
Adds parent resolution and deferred-container lifecycle handling. |
src/uipath_langchain/guardrails/middlewares/_base.py |
Supplies tool identity to guardrail stages. |
pyproject.toml |
Bumps the package version to 0.21.12. |
Review effort: Balanced
| for container in waiting: | ||
| container.end(container.last_check_end or None) |
|
| _parent_resolver: GuardrailParentResolver | None = None | ||
|
|
||
|
|
||
| def register_guardrail_parent_resolver( |
There was a problem hiding this comment.
Make this API public before uipath-agents depends on it
UiPath/uipath-agents-python#935 imports register_guardrail_parent_resolver, close_deferred_guardrail_containers and close_guardrail_container_under from this private module: in the runtime factory at import time (factory.py:43-46), and in its guardrail, LLM and tool instrumentors. A rename here passes this repo's CI, and then every agent in uipath-agents fails to start, advanced or not.
Export them from a public module, and add a test that pins their names and signatures, so a breaking change shows up here first.




Summary
Lets the runtime choose where a middleware guardrail check's trace container goes.
register_guardrail_parent_resolverregisters aGuardrailParentResolverthat, given the scope, stage, component and call id, returns the span the container should open under. With no resolver registered, placement is unchanged.close_deferred_guardrail_containers/close_guardrail_container_under, so parallel calls and resumed runs keep their checks under the right model or tool call.guardrail_stage.Coded agents don't change unless a resolver is registered; uipath-agents registers one in its trace PR.
Split out of #1260 as a pure move, with no behaviour change.
Testing
TestParentResolvercovers resolved placement, deferred containers and closing them.tests/guardrailspasses (532); ruff and mypy are clean.🤖 Generated with Claude Code