Skip to main content
skill CX Codex

nemo-relay-instrument-context-isolation — Claude Code skill

The nemo-relay-instrument-context-isolation skill keeps NeMo Relay scope stacks separate across concurrent work and preserves event ancestry as tasks cross execution boundaries.

Apache-2.0 211 installs ★ 4,106 updated 2026-10-23

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add NVIDIA/skills --skill nemo-relay-instrument-context-isolation -a claude-code
Open on GitHub

What nemo-relay-instrument-context-isolation does

The skill treats scope-stack ownership as part of the request boundary. Each request, agent, or workflow gets its own stack, while nested scopes form a parent-child tree. That tree controls event ancestry, lifetime, and visibility for scope-local middleware and subscribers. Scope boundaries can carry semantic input and output values, while mark events cover retries, checkpoints, interrupts, and other state changes.

The guidance maps the model to several runtimes. Python uses get_scope_stack() with contextvars; Rust integrations can use create_scope_stack() and set_thread_scope_stack(...); Go uses NewScopeStack() and ScopeStack.Run(...); Node.js uses createScopeStack() and setThreadScopeStack(...). Registrations tied to a scope disappear when it closes. A thread-local stack is unsafe after crossing an async task, goroutine, or JavaScript worker boundary.

What it helps with

  • isolate scope stacks for concurrent requests
  • preserve NeMo Relay event ancestry
  • propagate scope into async tasks and workers
  • prevent middleware from leaking between agents
  • mark retries and checkpoints without full spans

Example prompts for the agent

  • Give each concurrent request its own NeMo Relay scope stack and preserve event ancestry.
  • Show how to propagate the active scope across goroutines with NewScopeStack() and ScopeStack.Run(...).
  • Set up Node.js context isolation with createScopeStack() and setThreadScopeStack(...).

How to install nemo-relay-instrument-context-isolation

1Skills CLI (Vercel)

npx skills add NVIDIA/skills --skill nemo-relay-instrument-context-isolation -a claude-code

2Manually: put the files in place

~/.claude/skills/nemo-relay-instrument-context-isolation/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/nemo-relay-instrument-context-isolation/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about nemo-relay-instrument-context-isolation

How do I install nemo-relay-instrument-context-isolation in Claude Code?

Run npx skills add NVIDIA/skills --skill nemo-relay-instrument-context-isolation -a claude-code, then check ~/.claude/skills/nemo-relay-instrument-context-isolation/SKILL.md.

What does nemo-relay-instrument-context-isolation do?

It guides the agent to give each request, agent, or workflow an independent scope stack and maintain parent-child event ancestry. It also covers scope-local middleware and context propagation across concurrent work.

How does the skill handle different runtimes?

It uses contextvars for Python, stack helpers such as NewScopeStack() and ScopeStack.Run(...) for Go, and explicit stack setup with createScopeStack() and setThreadScopeStack(...) for Node.js. Rust integrations have their own stack helpers.

Source text

SKILL.md · Apache-2.0
---
name: nemo-relay-instrument-context-isolation
description: Use this skill when concurrent requests, async tasks, threads, workers, goroutines, or agents need independent NeMo Relay scope stacks and correct ancestry propagation.
license: Apache-2.0
metadata:
  author: NVIDIA Corporation and Affiliates
---

# Use Context Isolation

Use this skill when an application runs concurrent requests, worker pools, async
tasks, goroutines, or multiple agents in the same process.
Treat scope-stack ownership as part of the request boundary.

## Core Rule

Each independent request, agent, or workflow needs its own scope stack. Do not
share one mutable stack across unrelated concurrent work unless you want shared
ancestry and shared scope-local middleware.

## Embedded Scope Model

- A root scope is always present, and pushed scopes form a parent-child tree
  beneath it.
- Scope hierarchy determines event parentage, lifetime boundaries, and
  visibility for scope-local middleware and subscribers.
- Standard scope types include `Agent`, `Function`, `Tool`, `Llm`,
  `Retriever`, `Embedder`, `Reranker`, `Guardrail`, `Evaluator`, `Custom`, and
  `Unknown`.
- Scope start and end events can carry semantic `input` and `output` payloads
  when the scope represents a request, task, or meaningful result boundary.
- Scope-local registrations disappear when the owning scope closes; use them
  for behavior that should not outlive a request or agent run.
- Mark events are useful for retries, checkpoints, interrupts, and important
  state transitions that are not full spans.

## Per-Language Defaults

- **Python**: rely on task-local behavior via `get_scope_stack()` and
  `contextvars`, or explicitly propagate when work leaves the current execution
  context
- **Rust core**: use runtime helpers such as `create_scope_stack()`,
  `current_scope_stack()`, and `set_thread_scope_stack(...)` when an integration
  needs explicit stack ownership
- **Go**: use `NewScopeStack()` and `ScopeStack.Run(...)` for goroutine-safe
  usage
- **Node.js**: create and set a scope stack explicitly for the current execution
  path with `createScopeStack()` and `setThreadScopeStack(...)`

## Common Failures

- Events from different requests appear under one root UUID
- Scope-local middleware leaks across requests
- Worker-thread work runs without the expected active scope
- Integrations activate NeMo Relay without an explicitly initialized stack
- Relying on a thread-local stack after crossing async tasks, goroutines, or JS
  worker boundaries

## Related Skills

- `nemo-relay-instrument-calls`
- `nemo-relay-plugin-observability`
- `nemo-relay-debug-runtime-integration`

© NVIDIA Corporation and Affiliates · Apache-2.0 · NVIDIA/skills

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set312

The whole set →
earth2studio-create-diagnostic earth2studio-create-diagnostic is a Claude Code skill that creates diagnostic model wrappers for Earth2Studio, turning third-party single-step transforms into Python classes with tests and docs. CX Codex +1 581installs earth2studio-create-prognostic earth2studio-create-prognostic guides an agent through building an Earth2Studio wrapper for a weather model that forecasts future states over successive time steps. CX Codex +1 579installs nemo-relay-install The nemo-relay-install skill identifies your installation target and deploys the current stable NeMo Relay package, resolving prerequisites and verifying availability. Works across agent runtimes, frameworks, and language bindings. CX Codex +1 227installs nemo-relay-instrument-calls nemo-relay-instrument-calls wraps tool and LLM provider call sites with NeMo Relay execution scopes. Keeps business logic intact while attaching lifecycle events, intercepts, and guardrails. CX Codex +1 224installs nemotron-asr-finetune nemotron-asr-finetune coordinates domain and language adaptation for NVIDIA Nemotron Speech and Riva ASR, picking the lowest-cost path from word boosting to full fine-tuning. CX Codex +1 210installs nemo-relay-debug-runtime-integration The nemo-relay-debug-runtime-integration skill traces NeMo Relay runtime faults across loading, scopes, events, plugins, and adaptive wiring. Use it when the package is present but app behavior is wrong. CX Codex +1 197installs nemo-relay-instrument-typed-wrappers nemo-relay-instrument-typed-wrappers configures NeMo Relay typed wrappers and provider codecs while keeping JSON middleware semantics intact. CX Codex +1 182installs nemo-relay-plugin-build nemo-relay-plugin-build is a skill for packaging reusable NeMo Relay behavior as config components or dynamic plugins, with validation and rollback for plugins shared across apps or teams. CX Codex +1 181installs

Project sponsors

Companies that keep this analytics open