nat.plugins.adk.adk_callback_handler#

Attributes#

Classes#

ADKProfilerHandler

A callback manager/handler for Google ADK that intercepts calls to:

Module Contents#

logger#
class ADKProfilerHandler#

Bases: nat.profiler.callbacks.base_callback_class.BaseProfilerCallback

A callback manager/handler for Google ADK that intercepts calls to:
  • Tools

  • LLMs

to collect usage statistics (tokens, inputs, outputs, time intervals, etc.) and store them in NeMo Agent Toolkit’s usage_stats queue for subsequent analysis.

_lock#
last_call_ts#
step_manager#
_original_tool_call = None#
_original_llm_call = None#
_instrumented = False#
instrument() None#

Monkey-patch the relevant Google ADK methods with usage-stat collection logic. Assumes the ‘google-adk’ library is installed.

uninstrument() None#

Restore the original Google ADK methods. Add an explicit unpatch to avoid side-effects across tests/process lifetime.

_tool_use_monkey_patch() collections.abc.Callable[Ellipsis, Any]#

Returns a function that wraps calls to BaseTool.run_async with usage-logging.

_llm_call_monkey_patch() collections.abc.Callable[Ellipsis, Any]#

Returns a function that wraps calls to litellm.acompletion(…) with usage-logging.

Returns:

Callable[…, Any]: The wrapped function.