fix(traceview): push the id ReferenceId resolves to onto the hierarchy - #1115
Merged
Merged
Conversation
The langgraph entry carried UIPATH_AGENT_ID, but a span's ReferenceId is derived as `agentId or referenceId`, with `agentId` set from resolve_project_id() — which prefers uipath.json#id. Whenever the two disagreed the hierarchy leaf and ReferenceId named different entities. Also guard the push against a non-UUID id: env-var sources are unvalidated, so ReferenceContext.add() could raise straight out of execute()/stream(). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Separate the optional imports so missing resolve_project_id does not disable ReferenceContext on older uipath versions.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Fixes hierarchy IDs to match ReferenceId and safely skips invalid UUIDs.
Changes:
- Resolves project IDs with environment fallback.
- Adds invalid-ID handling.
- Adds regression coverage for precedence, fallback, and invalid IDs.
| File | Description |
|---|---|
tests/runtime/test_reference_context_wiring.py |
Tests hierarchy/reference ID alignment and invalid-ID behavior. |
src/uipath_langchain/runtime/runtime.py |
Updates hierarchy ID resolution and validation handling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
JosephMar
approved these changes
Sep 25, 2026
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




langgraphentry pushed onto the reference hierarchy named a different entity than the span's ownReferenceId._push_reference_context()reados.environ["UIPATH_AGENT_ID"]directly, while_SpanUtils.otel_span_to_uipath_spanderivesReferenceIdasagentId or referenceIdwithagentIdset fromresolve_project_id()— which prefersuipath.json#idand only then falls back to the env var. Wheneveruipath.json#idexisted, the leaf andReferenceIddiverged.resolve_project_id() or UIPATH_AGENT_ID.resolve_project_idjoins the same guardeduipath.tracingimport, so olderuipathpackages still degrade to the existing no-op shim. The resolution order insideresolve_project_id()is left completely untouched.ValueErrorguard.ReferenceContext.add()validates UUIDs and env-var sources are unvalidated, so a non-UUIDUIPATH_AGENT_IDraised straight out ofexecute()/stream()and failed the run. It now skips the entry, matching whatuipath-agents-pythonalready does.Behaviour
With
uipath.json#id = 1111…andUIPATH_AGENT_ID = 2222…:ReferenceId1111…1111…unchanged2222…1111…With no
uipath.json#id, both are2222…before and after — which is why the existing wiring tests pass unchanged.Tests
TestHierarchyLeafMatchesReferenceIdintests/runtime/test_reference_context_wiring.py:uipath.json#idwins overUIPATH_AGENT_ID;UIPATH_AGENT_IDwhen nouipath.jsonexists;The first and third fail against
mainand pass with this change. Fulltests/runtimesuite green; ruff + mypy clean.Companion
uipath-agents-pythonhas the same divergence for itsagententry — fixed the same way in UiPath/uipath-agents-python#768.🤖 Generated with Claude Code