Skip to content

Forward-merge release/0.6 into main#471

Merged
GPUtester merged 1 commit into
mainfrom
release/0.6
Jul 17, 2026
Merged

Forward-merge release/0.6 into main#471
GPUtester merged 1 commit into
mainfrom
release/0.6

Conversation

@rapids-bot

@rapids-bot rapids-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

Forward-merge triggered by push to release/0.6 that creates a PR to keep main up-to-date. If this PR is unable to be immediately merged due to conflicts, it will remain open for the team to manually merge. See forward-merger docs for more info.

#### Overview

Restore the active task's Python scope stack before every context-sensitive native lifecycle call. This prevents concurrent asyncio tasks from closing scopes or invoking tool/LLM middleware against a sibling task's stack.

- [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does not duplicate existing work.

#### Details

- Centralize ContextVar-to-native stack synchronization in a private helper.
- Apply synchronization to scope, tool, and LLM lifecycle wrappers, including managed and streaming execution.
- Close context-manager scopes through the synchronized `pop()` wrapper.
- Add concurrent asyncio regressions for scope cleanup, middleware isolation, lifecycle helpers, and event ancestry.

#### Where should the reviewer start?

Start with `python/nemo_relay/_context.py`, then `python/tests/test_context_isolation.py` for the concurrent task coverage.

#### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

- Fixes RELAY-497



## Summary by CodeRabbit

* **Bug Fixes**
  * Improved scope and context handling for concurrent operations.
  * Ensured tool and LLM lifecycle events remain associated with the correct task.
  * Improved cleanup when scoped operations complete, including status metadata handling.

* **Tests**
  * Added coverage for concurrent tool and LLM operations.
  * Added validation for task-local scope restoration and event ancestry.

Authors:
  - Will Killian (https://github.com/willkill07)

Approvers:
  - Maryam Najafian (https://github.com/mnajafian-nv)

URL: #462
@rapids-bot
rapids-bot Bot requested a review from a team as a code owner July 17, 2026 17:37
@GPUtester
GPUtester merged commit 0e71da5 into main Jul 17, 2026
2 checks passed
@rapids-bot

rapids-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown
Author

SUCCESS - forward-merge complete.

@github-actions github-actions Bot added size:M PR is medium lang:python PR changes/introduces Python code labels Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang:python PR changes/introduces Python code size:M PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants