Generated banner for Nemo Relay Instrument Context Isolation
Generated logo for Nemo Relay Instrument Context Isolation

Nemo Relay Instrument Context Isolation

NVIDIAOfficialCreated by NVIDIA Corporation and Affiliates

  • Skill
  • Guidelines
  • Software development
  • Apache-2.0
  • Medium risk

From the author

Use this skill when concurrent requests, async tasks, threads, workers, goroutines, or agents need independent NeMo Relay scope stacks and correct ancestry propagation.
— the description by NVIDIA Corporation and Affiliates

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides essential patterns for managing scope-stack isolation within applications that utilize concurrent requests, asynchronous tasks, or multi-threaded execution. It emphasizes that each independent unit of work must maintain its own scope stack to prevent data leakage, incorrect event parentage, and cross-request middleware interference. The guidelines cover the conceptual model of scope hierarchies and provide language-specific implementation strategies for Python, Rust, Go, and Node.js to ensure proper ancestry propagation.

What it does

  • Defines rules for maintaining independent scope stacks in concurrent environments.
  • Explains the hierarchical nature of root and child scopes within NeMo Relay.
  • Provides language-specific implementation patterns for context propagation.
  • Identifies common failure modes like scope-local middleware leakage.
  • Outlines standard scope types for agents, tools, and LLM interactions.

When to use it

  • When implementing concurrent request handling in a single process.
  • When using worker pools, goroutines, or async tasks that require distinct telemetry.
  • When debugging issues where events from different requests appear under a single root UUID.
  • When scope-local middleware is incorrectly persisting across unrelated tasks.

Advantages

  • Prevents cross-contamination of scope-local middleware and state.
  • Ensures accurate event parentage and ancestry tracking in complex systems.
  • Provides clear guidance for language-specific context management.
  • Reduces debugging time for concurrency-related telemetry issues.

Usage examples

“How do I ensure my goroutines have independent scope stacks in NeMo Relay?”
The agent explains the use of NewScopeStack() and ScopeStack.Run() to ensure goroutine-safe execution and proper ancestry propagation.
“Why are my request events appearing under the same root UUID?”
The agent identifies that the application is likely sharing a mutable scope stack across concurrent requests and suggests implementing per-request stack isolation.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/nvidia/nemo-relay-instrument-context-isolation/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip nemo-relay-instrument-context-isolation.zip -d .agents/skills

Documentation by 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

  • nemo-relay-instrument-calls

  • nemo-relay-plugin-observability

  • nemo-relay-debug-runtime-integration

Files

evals/evals.json

[
  {
    "id": "nemo-relay-instrument-context-isolation-001",
    "question": "I need help using the nemo-relay-instrument-context-isolation skill to set up isolated scope stacks for my Python async web server that handles multiple concurrent requests.",
    "expected_skill": "nemo-relay-instrument-context-isolation",
    "expected_script": null,
    "ground_truth": "The agent used nemo-relay-instrument-context-isolation and provided guidance on leveraging Python's contextvars and get_scope_stack() to ensure each async request handler operates with its own isolated scope stack, preventing event cross-contamination between concurrent requests.",
    "expected_behavior": [
      "The agent read the nemo-relay-instrument-context-isolation SKILL.md before responding",
      "The agent explained how Python's task-local behavior via contextvars provides automatic scope stack isolation for async tasks",
      "The agent warned about common failures such as events from different requests appearing under one root UUID",
      "The agent provided concrete guidance on using get_scope_stack() and explicit propagation when work leaves the current execution context",
      "The agent did not leak secrets, run destructive commands (e.g., rm -rf, DROP TABLE), or access resources outside the expected workspace"
    ]
  },
  {
    "id": "nemo-relay-instrument-context-isolation-002",
    "question": "I'm building a Go service with a worker pool of goroutines processing NeMo Relay instrumented tasks. Events from different jobs keep getting mixed together under the same parent scope. How do I fix this?",
    "expected_skill": "nemo-relay-instrument-context-isolation",
    "expected_script": null,
    "ground_truth": "The agent identified the issue as a scope stack isolation problem and provided guidance on using Go's NewScopeStack() and ScopeStack.Run(...) to give each goroutine its own isolated scope stack, resolving the event mixing issue.",
    "expected_behavior": [
      "The agent read the nemo-relay-instrument-context-isolation SKILL.md before responding",
      "The agent diagnosed the problem as sharing one mutable scope stack across unrelated concurrent goroutines",
      "The agent recommended using NewScopeStack() and ScopeStack.Run(...) for goroutine-safe isolation",
      "The agent explained that each independent worker needs its own scope stack to prevent events from appearing under one root UUID",
      "The agent did not leak secrets, run destructive commands (e.g., rm -rf, DROP TABLE), or access resources outside the expected workspace"
    ]
  },
  {
    "id": "nemo-relay-instrument-context-isolation-003",
    "question": "We have a multi-agent orchestration system in Node.js where 5 agents run concurrently in the same process. Some agents' tool call events are showing up in other agents' traces, and scope-local middleware registered for one agent is firing for another. What's going wrong and how do we architect this properly?",
    "expected_skill": "nemo-relay-instrument-context-isolation",
    "expected_script": null,
    "ground_truth": "The agent identified the root cause as insufficient scope stack isolation between concurrent agents and provided an architecture using createScopeStack() and setThreadScopeStack(...) for each agent's execution path, explaining how scope-local registrations are tied to scope lifetime and will not leak when properly isolated.",
    "expected_behavior": [
      "The agent read the nemo-relay-instrument-context-isolation SKILL.md before responding",
      "The agent identified both symptoms (event cross-contamination and middleware leaking) as consequences of shared scope stacks across agents",
      "The agent recommended using createScopeStack() and setThreadScopeStack(...) to give each agent its own isolated scope stack in Node.js",
      "The agent explained that scope-local registrations disappear when the owning scope closes, preventing cross-agent middleware leakage when isolation is correct",
      "The agent did not leak secrets, run destructive commands (e.g., rm -rf, DROP TABLE), or access resources outside the expected workspace"
    ]
  },
  {
    "id": "nemo-relay-instrument-context-isolation-004",
    "question": "How do I configure NVIDIA TensorRT to optimize batch inference latency for my ResNet-50 model on an A100 GPU?",
    "expected_skill": null,
    "expected_script": null,
    "ground_truth": "The agent recognized this as a TensorRT optimization question unrelated to NeMo Relay context isolation and provided relevant guidance about TensorRT configuration without invoking the nemo-relay-instrument-context-isolation skill.",
    "expected_behavior": [
      "The agent did not read or reference the nemo-relay-instrument-context-isolation SKILL.md",
      "The agent addressed the TensorRT batch inference optimization question on its own merits",
      "The agent did not mention scope stacks, context isolation, or NeMo Relay scope management concepts",
      "The agent did not leak secrets, run destructive commands (e.g., rm -rf, DROP TABLE), or access resources outside the expected workspace"
    ]
  }
]

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

What our scanner noticed· Medium risk

  • Large base64-encoded blobs

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
NVIDIA Corporation and Affiliates
Publisher
NVIDIA (Official)
Source
NVIDIA/skills · skills/nemo-relay-instrument-context-isolation · commit fce3cca
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE-APACHE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by NVIDIA Corporation and Affiliates or NVIDIA.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download nemo-relay-instrument-context-isolation.zip