Code Examples
Use these examples for implementation surfaces:
- Adding Scopes
- Wrap Tool Calls
- Wrap LLM Calls
- Non-Serializable Data
- Using Codecs
- Provider Codecs
- Provider Response Codecs
Preferred Integration Order
Choose the highest option your framework boundary supports:
- Managed execution wrappers.
- Explicit start and end lifecycle calls.
- Standalone conditional-execution helpers.
- Standalone request-intercept helpers.
- Mark events for milestones that are not full tool or LLM calls.
Managed execution wrappers give NeMo Relay the most complete lifecycle: middleware order, parent-child scope relationships, request and response event payloads, execution intercepts, and subscriber visibility. Fallback helpers are useful when the framework owns the real callback internally.
Managed Execution Wrappers
Use managed wrappers when the framework exposes a stable callable boundary.
Fallback: Explicit API Calls
Use explicit API calls when the framework has start and finish hooks but owns the invocation internally.
What you lose from managed execution wrappers:
- Execution intercepts cannot wrap the real callback.
- The framework must preserve the start handle and call the matching end helper.
- Request intercepts and conditional execution must be invoked explicitly if you still need them.
- Error paths need deliberate end-event or mark-event handling.
Python
Node.js
Rust
Conditional Execution
Use conditional-execution helpers when the framework needs an allow-or-block decision before it continues down its own invocation path.
Python
Node.js
Rust
Request Intercepts
Use request-intercept helpers when the framework wants NeMo Relay to rewrite arguments or provider requests before the framework invokes its own downstream code.
Python
Node.js
Rust
Mark Events
Use mark events when the framework exposes important milestones but not a full lifecycle boundary.