> 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 AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/relay/_mcp/server.

# Struct Plugin Context

> Registration context passed to `WorkerPlugin::register`.

Generated from `cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker`.

```rust
pub struct PluginContext { /* private fields */ }
```

Registration context passed to [`WorkerPlugin::register`](/reference/api/rust-library-reference/nemo-relay-worker/trait-workerplugin).

## Implementations

### `impl PluginContext`

<pre />

#### `new`

<pre />

Creates an empty worker registration context.

#### `with_runtime`

<pre />

Creates an empty worker registration context with a host runtime handle.

#### `runtime`

<pre />

Returns the host runtime handle for event and scope operations.

#### `register_subscriber`

<pre />

Registers an event subscriber.

#### `register_mark_sanitize_guardrail`

<pre />

Registers a mark event sanitizer.

#### `register_scope_sanitize_start_guardrail`

<pre />

Registers a scope-start event sanitizer.

#### `register_scope_sanitize_end_guardrail`

<pre />

Registers a scope-end event sanitizer.

#### `register_tool_sanitize_request_guardrail`

<pre />

Registers a tool sanitize-request guardrail.

#### `register_tool_sanitize_response_guardrail`

<pre />

Registers a tool sanitize-response guardrail.

#### `register_tool_conditional_execution_guardrail`

<pre />

Registers a tool conditional-execution guardrail.

#### `register_tool_request_intercept`

<pre />

Registers a tool request intercept.

#### `register_tool_execution_intercept`

<pre />

Registers a tool execution intercept.

The callback returns a [`ToolExecutionInterceptOutcome`](/reference/api/rust-library-reference/nemo-relay-worker/struct-toolexecutioninterceptoutcome). Calling [`ToolNext::call`](/reference/api/rust-library-reference/nemo-relay-worker/struct-toolnext) continues the chain and returns only the raw downstream result JSON; Relay retains downstream pending marks. `ToolNext` may be called repeatedly or concurrently while the callback is active. Each call snapshots its visible worker scope stack, and Relay rejects late calls or cancels unfinished calls when the callback settles.

#### `register_llm_sanitize_request_guardrail`

<pre />

Registers an LLM sanitize-request guardrail.

#### `register_llm_sanitize_response_guardrail`

<pre />

Registers an LLM sanitize-response guardrail.

#### `register_llm_conditional_execution_guardrail`

<pre />

Registers an LLM conditional-execution guardrail.

#### `register_llm_request_intercept`

<pre />

Registers an LLM request intercept.

#### `register_llm_execution_intercept`

<pre />

Registers an LLM execution intercept.

[`LlmNext::call`](/reference/api/rust-library-reference/nemo-relay-worker/struct-llmnext) may run repeatedly or concurrently while the callback is active. Each call snapshots its visible worker scope stack, and Relay rejects late calls or cancels unfinished calls when the callback settles.

#### `register_llm_stream_execution_intercept`

<pre />

Registers an LLM stream execution intercept.

[`LlmStreamNext::call`](/reference/api/rust-library-reference/nemo-relay-worker/struct-llmstreamnext) may run repeatedly or concurrently. Each call snapshots its visible worker scope stack. The interceptor's returned stream keeps the callback active until it closes; Relay then rejects late calls and cancels unfinished calls.

## Trait Implementations

### `impl Default for PluginContext`

<pre />

#### `default`

<pre />