Use this guide when you have an application tool callback and want NeMo Relay to emit lifecycle events, apply middleware, and preserve the active agent scope around the call.
You will wrap one existing tool callback with the managed tool execution API. The result is a tool call that:
Complete one binding Quick Start guide first:
Create a scope for the active request or agent run before adding tool instrumentation. If you have not done that yet, start with Adding Scopes and Marks.
The tool arguments and result must be JSON-compatible. If your framework passes clients, sockets, streams, callbacks, or other opaque objects, use Handle Non-Serializable Data before you instrument the callback.
Follow this sequence to keep framework work attached to the expected runtime context.
The examples below wrap a search callback and print emitted events.
Check both behavior and instrumentation:
search.Native subscriber delivery is asynchronous. Flush subscribers before validating
printed output. In Node.js, also wait one event-loop tick after
flushSubscribers() so JavaScript callbacks can run.
If only the business result appears, the callback ran but instrumentation did not run. Confirm that the call goes through tools.execute, toolCallExecute, or tool_call_execute.
Use this checklist before running the pattern in production traffic.
search.redact_args or retrieval.timeout.Check these symptoms first when the workflow does not behave as expected.
Use these links to continue from this workflow into the next related task.