Skip to content

feat: propagate reference hierarchy context from LangGraph runtime#901

Open
jepadil23 wants to merge 13 commits into
mainfrom
feat/reference-hierarchy-context
Open

feat: propagate reference hierarchy context from LangGraph runtime#901
jepadil23 wants to merge 13 commits into
mainfrom
feat/reference-hierarchy-context

Conversation

@jepadil23

Copy link
Copy Markdown

Summary

  • UiPathLangGraphRuntime._push_reference_context() pushes a "langgraph" entry into ReferenceContextAccessor during execute() and stream(), resets in finally
  • All spans emitted by LangGraph nodes within the run automatically carry the full reference hierarchy (maestro → agent → langgraph) in their Context.referenceHierarchy wire payload

Dependencies

Requires uipath-python PR #1708 (ReferenceContext / ReferenceContextAccessor types).

Test plan

  • tests/runtime/test_reference_context_wiring.py — verifies referenceHierarchy is present in LangGraph runtime spans with correct serviceType="langgraph" entry
  • Verify context resets correctly after execute/stream completes

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 10, 2026 19:14

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

This PR adds propagation of an ambient ReferenceContext for UiPathLangGraphRuntime runs so that downstream tracing can attribute spans to a langgraph service entry layered on top of any parent reference hierarchy.

Changes:

  • Add UiPathLangGraphRuntime._push_reference_context() and wrap execute()/stream() with push/reset in try/finally.
  • Introduce a new test module covering context stacking behavior and ensuring the context is reset after execute()/stream() (including error paths).

Reviewed changes

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

File Description
src/uipath_langchain/runtime/runtime.py Pushes a langgraph entry into ReferenceContextAccessor during execute()/stream() and resets it in finally.
tests/runtime/test_reference_context_wiring.py Adds tests for _push_reference_context() and for context reset after runtime execution/streaming.

Comment thread src/uipath_langchain/runtime/runtime.py Outdated
Comment thread tests/runtime/test_reference_context_wiring.py Outdated
Comment thread tests/runtime/test_reference_context_wiring.py Outdated
Comment thread tests/runtime/test_reference_context_wiring.py Outdated
Comment thread tests/runtime/test_reference_context_wiring.py Outdated
Comment thread tests/runtime/test_reference_context_wiring.py Outdated
Comment thread tests/runtime/test_reference_context_wiring.py Outdated
Comment thread tests/runtime/test_reference_context_wiring.py Outdated
Comment thread tests/runtime/test_reference_context_wiring.py
@saksharthakkar

Copy link
Copy Markdown
Contributor

Please make sure to address the review comments by Copilot and address these CI requirements

@saksharthakkar

Copy link
Copy Markdown
Contributor

you'll need to bump up version here

@jepadil23

Copy link
Copy Markdown
Author

@claude

jepadil23 and others added 3 commits July 5, 2026 22:07
… runtime

UiPathLangGraphRuntime._push_reference_context() reads any parent
ReferenceContext set by upstream (e.g. agents-python start_agent_run),
appends a "langgraph" entry from UIPATH_AGENT_ID / UIPATH_PROCESS_VERSION,
and activates it via ReferenceContextAccessor. Both execute() and
stream() call this at entry and reset in finally, so all child spans
emitted during the run carry the full hierarchy in their
Context.referenceHierarchy wire payload.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@jepadil23 jepadil23 force-pushed the feat/reference-hierarchy-context branch from b08070a to 65fdb0c Compare July 6, 2026 05:11
@jepadil23 jepadil23 force-pushed the feat/reference-hierarchy-context branch from 7015ffe to 7e1f7d8 Compare July 6, 2026 06:15
@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
75.9% Coverage on New Code (required ≥ 90%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants