ADK for TypeScript: API Reference
    Preparing search index...

    Class DebugLoggingPlugin

    A plugin that captures complete debug information to a YAML file.

    This plugin records detailed interaction data including:

    • LLM requests (model, system instruction, contents, tools)
    • LLM responses (content, usage metadata, errors)
    • Function calls with arguments
    • Function responses with results
    • Events yielded from the runner
    • Session state at the end of each invocation

    Each invocation is appended to the output file as a separate YAML document (separated by ---). Credentials, sensitive keys, temp:-scoped state keys, and armored private key blocks are automatically redacted to [REDACTED].

    Hierarchy (View Summary)

    "[DEBUG_LOGGING_PLUGIN_SYMBOL]": true
    includeSessionState: boolean
    includeSystemInstruction: boolean
    name: string
    outputPath: string
    • Callback executed after an agent's primary logic has completed.

      This callback can be used to inspect, log, or modify the agent's final result before it is returned.

      Parameters

      Returns Promise<Content | undefined>

      An optional Content object. If a value is returned, it will replace the agent's original result. Returning undefined uses the original, unmodified result.

    • Callback executed after a response is received from the model.

      This is the ideal place to log model responses, collect metrics on token usage, or perform post-processing on the raw LlmResponse.

      Parameters

      Returns Promise<LlmResponse | undefined>

      An optional value. A non-undefined return may be used by the framework to modify or replace the response. Returning undefined allows the original response to be used.

    • Callback executed after a workflow node has run.

      Not called for a node whose body was skipped by beforeNodeCallback, and not called when the node throws.

      Parameters

      • params: { node: BaseNode; nodeContext: NodeContext; output: unknown }
        • node: BaseNode

          The node that has just run.

        • nodeContext: NodeContext

          The node's execution context.

        • output: unknown

          The output the node produced.

      Returns Promise<unknown>

      An optional value replacing the node's output. Returning undefined keeps the original.

    • Callback executed after a tool has been called.

      This callback allows for inspecting, logging, or modifying the result returned by a tool.

      Parameters

      • __namedParameters: {
            result: Record<string, unknown>;
            tool: BaseTool;
            toolArgs: Record<string, unknown>;
            toolContext: Context;
        }

      Returns Promise<Record<string, unknown> | undefined>

      An optional dictionary. If a dictionary is returned, it will replace the original result from the tool. This allows for post-processing or altering tool outputs. Returning undefined uses the original, unmodified result.

    • Callback executed before an agent's primary logic is invoked.

      This callback can be used for logging, setup, or to short-circuit the agent's execution by returning a value.

      Parameters

      Returns Promise<Content | undefined>

      An optional Content object. If a value is returned, it will bypass the agent's callbacks and its execution, and return this value directly. Returning undefined allows the agent to proceed normally.

    • Callback executed before a request is sent to the model.

      This provides an opportunity to inspect, log, or modify the LlmRequest object. It can also be used to implement caching by returning a cached LlmResponse, which would skip the actual model call.

      Parameters

      Returns Promise<LlmResponse | undefined>

      An optional value. The interpretation of a non-undefined trigger an early exit and returns the response immediately. Returning undefined allows the LLM request to proceed normally.

    • Callback executed before a workflow node runs.

      Parameters

      • params: { input: unknown; node: BaseNode; nodeContext: NodeContext }
        • input: unknown

          The input the node is about to receive.

        • node: BaseNode

          The node that is about to run.

        • nodeContext: NodeContext

          The node's execution context.

      Returns Promise<unknown>

      An optional value. If anything other than undefined is returned, the node's body is skipped and the returned value becomes its output, which is how a plugin implements a node-level cache or a stub. Returning undefined lets the node run normally.

    • Callback executed before the ADK runner runs.

      This is the first callback to be called in the lifecycle, ideal for global setup or initialization tasks.

      Parameters

      Returns Promise<Content | undefined>

      An optional Event to be returned to the ADK. Returning a value to halt execution of the runner and ends the runner with that event. Return undefined to proceed normally.

    • Callback executed before a tool is called.

      This callback is useful for logging tool usage, input validation, or modifying the arguments before they are passed to the tool.

      Parameters

      • __namedParameters: { tool: BaseTool; toolArgs: Record<string, unknown>; toolContext: Context }

      Returns Promise<Record<string, unknown> | undefined>

      An optional dictionary. If a dictionary is returned, it will stop the tool execution and return this response immediately. Returning undefined uses the original, unmodified arguments.

    • Callback executed before a tool is selected.

      This callback provides an opportunity to inspect, log, or modify the available tools before they are selected.

      Parameters

      • _params: { callbackContext: Context; tools: Readonly<Record<string, BaseTool>> }
        • callbackContext: Context

          The context for the current agent call.

        • tools: Readonly<Record<string, BaseTool>>

          The available tools.

      Returns Promise<Readonly<Record<string, BaseTool>> | undefined>

      An optional value. A non-undefined return may be used by the framework to modify or replace the available tools. Returning undefined allows the original tools to be used.

    • Callback executed after an event is yielded from runner.

      This is the ideal place to make modification to the event before the event is handled by the underlying agent app.

      Parameters

      Returns Promise<Event | undefined>

      An optional value. A non-undefined return may be used by the framework to modify or replace the response. Copy the incoming event when constructing a replacement to preserve fields that are not being modified, such as event actions. Returning undefined allows the original response to be used.

    • Callback executed when a model call encounters an error.

      This callback provides an opportunity to handle model errors gracefully, potentially providing alternative responses or recovery mechanisms.

      Parameters

      • __namedParameters: { callbackContext: Context; error: Error; llmRequest: LlmRequest }

      Returns Promise<LlmResponse | undefined>

      An optional LlmResponse. If an LlmResponse is returned, it will be used instead of propagating the error. Returning undefined allows the original error to be raised.

    • Callback executed when a tool call encounters an error. tool: BaseTool; toolArgs: Record<string, unknown>; toolContext: Context; result: Record<string, unknown>; }): Promise<Record<string, unknown> | undefined> { return; }

      /** Callback executed when a tool call encounters an error.

      This callback provides an opportunity to handle tool errors gracefully, potentially providing alternative responses or recovery mechanisms.

      Parameters

      • __namedParameters: {
            error: Error;
            tool: BaseTool;
            toolArgs: Record<string, unknown>;
            toolContext: Context;
        }

      Returns Promise<Record<string, unknown> | undefined>

      An optional dictionary. If a dictionary is returned, it will be used as the tool response instead of propagating the error. Returning undefined allows the original error to be raised.

    • Callback executed when a user message is received before an invocation starts.

      This callback helps logging and modifying the user message before the runner starts the invocation.

      Parameters

      Returns Promise<Content | undefined>

      An optional Content to be returned to the ADK. Returning a value to replace the user message. Returning undefined to proceed normally.

    • Safely serializes an arbitrary value to a YAML/JSON-compatible format with credential, sensitive key, and private key redaction.

      Parameters

      • obj: unknown
      • depth: number = 0

      Returns unknown

    • Serializes a Gemini Content object to a dictionary for YAML output.

      Parameters

      • content: Content | null | undefined

      Returns Record<string, unknown> | null