Commit d763f4f
feat(governance): platform self-resolves trace_id when caller leaves it empty
Lets the runtime layer (uipath-runtime-python) stop carrying ``trace_id``
through ``UiPathGovernedRuntime`` / ``GuardrailCompensator``. The runtime
emits compensation requests with ``trace_id=""`` and the platform fills
in the canonical agent trace id at HTTP-call time via the existing
``resolve_trace_id()`` helper — same fallback ``track_event`` (PR #1745)
already uses.
uipath-core
- ``GovernRequest.trace_id`` relaxes from required ``str`` to ``str = ""``
default. Docstring documents the platform-side self-resolve contract
so wire callers know an empty value is legitimate.
uipath-platform
- ``GovernanceService._compensate`` / ``_compensate_async`` now call a
new ``_resolve_request_trace_id()`` helper before the POST. When
``request.trace_id`` is empty the helper resolves via
``resolve_trace_id()`` (env → LLMOps external span → OTel current
span). Caller-supplied values win — the runtime captures live OTel
context across its background-pool hop via
``contextvars.copy_context()``, so when the worker calls
``provider.compensate(...)`` the platform-side resolver sees the
agent's live span and returns the same canonical id.
Caller-supplied non-empty trace ids continue to pass through unchanged.
Tests
- uipath-core governance suite: 32 passed.
- uipath-platform governance service suite: 27 passed.
- ruff + mypy clean on ``src/uipath/core/governance`` and
``src/uipath/platform/governance``.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent afcf7a5 commit d763f4f
2 files changed
Lines changed: 38 additions & 3 deletions
File tree
- packages
- uipath-core/src/uipath/core/governance
- uipath-platform/src/uipath/platform/governance
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
109 | 116 | | |
110 | 117 | | |
111 | 118 | | |
| |||
114 | 121 | | |
115 | 122 | | |
116 | 123 | | |
117 | | - | |
| 124 | + | |
118 | 125 | | |
119 | 126 | | |
120 | 127 | | |
| |||
Lines changed: 30 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
265 | 272 | | |
| 273 | + | |
266 | 274 | | |
267 | 275 | | |
268 | 276 | | |
269 | 277 | | |
270 | 278 | | |
271 | 279 | | |
272 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
273 | 285 | | |
274 | 286 | | |
275 | 287 | | |
276 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
277 | 305 | | |
278 | 306 | | |
279 | 307 | | |
| |||
0 commit comments