> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/relay/llms.txt.
> For full documentation content, see https://docs.nvidia.com/nemo/relay/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/relay/_mcp/server.

# Module context_helpers

> Context helpers for reading scope metadata on the intercept hot path.

Generated from `cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-ffi`.

Context helpers for reading scope metadata on the intercept hot path.

These functions read from the NeMo Relay scope stack (via [`current_scope_stack`](/reference/api/rust-library-reference/nemo-relay/api/runtime/scope_stack/fn-current-scope-stack)) to extract information needed by the LLM request intercept:

* [`extract_scope_path`](/reference/api/rust-library-reference/nemo-relay-adaptive/context_helpers/fn-extract-scope-path): collects function names from the scope stack for trie lookup
* [`read_manual_latency_sensitivity`](/reference/api/rust-library-reference/nemo-relay-adaptive/context_helpers/fn-read-manual-latency-sensitivity): walks all scopes for manual `latency_sensitive` annotations
* [`resolve_agent_id`](/reference/api/rust-library-reference/nemo-relay-adaptive/context_helpers/fn-resolve-agent-id): returns the first Agent scope name from the scope stack

All functions are safe to call from sync contexts (intercepts are sync closures). They acquire a read lock on the scope stack, which is always fast.

## Metadata Convention

Manual latency sensitivity is stored in scope metadata under the JSON path `/nemo_relay_adaptive/latency_sensitivity` as a positive integer.

## Structs

* [SharedParentScopeIdentity](/reference/api/rust-library-reference/nemo-relay-adaptive/context_helpers/struct-sharedparentscopeidentity): Session-local scope identity used to coordinate warm-first cohorts.

## Constants

* [LATENCY\_SENSITIVITY\_POINTER](/reference/api/rust-library-reference/nemo-relay-adaptive/context_helpers/constant-latency-sensitivity-pointer): Metadata key path for manual latency sensitivity annotation.

## Functions

* [extract\_scope\_path](/reference/api/rust-library-reference/nemo-relay-adaptive/context_helpers/fn-extract-scope-path): Extracts the current function call path from the NeMo Relay scope stack.
* [read\_manual\_latency\_sensitivity](/reference/api/rust-library-reference/nemo-relay-adaptive/context_helpers/fn-read-manual-latency-sensitivity): Reads the maximum manual latency sensitivity from all scopes in the current scope stack.
* [resolve\_agent\_id](/reference/api/rust-library-reference/nemo-relay-adaptive/context_helpers/fn-resolve-agent-id): Resolves the agent ID from the current scope stack.
* [resolve\_shared\_parent\_scope\_identity](/reference/api/rust-library-reference/nemo-relay-adaptive/context_helpers/fn-resolve-shared-parent-scope-identity): Resolves the session-local identity used by warm-first cohort coordination.
* [set\_latency\_sensitivity](/reference/api/rust-library-reference/nemo-relay-adaptive/context_helpers/fn-set-latency-sensitivity): Sets latency sensitivity on the current (top) scope using max-merge semantics.