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

    Class Context

    The context of various callbacks within an agent run.

    This class provides the context for callbacks and tool invocations, including access to the invocation context, function call ID, event actions, and authentication response. It also provides methods for requesting credentials, retrieving authentication responses, loading and saving artifacts, and searching memory.

    Hierarchy (View Summary)

    Constructors

    • Parameters

      • options: {
            eventActions?: EventActions;
            functionCallId?: string;
            invocationContext: InvocationContext;
            toolConfirmation?: ToolConfirmation;
        }

        The configuration options for the Context.

        • OptionaleventActions?: EventActions

          The event actions of the current call.

        • OptionalfunctionCallId?: string

          The function call id of the current tool call. This id was returned in the function call event from LLM to identify a function call. If LLM didn't return this id, ADK will assign one to it. This id is used to map function call response to the original function call.

        • invocationContext: InvocationContext

          The invocation context.

        • OptionaltoolConfirmation?: ToolConfirmation

          The tool confirmation of the current tool call.

      Returns Context

    Properties

    eventActions: EventActions
    functionCallId?: string
    invocationContext: InvocationContext
    toolConfirmation?: ToolConfirmation

    Accessors

    • get invocationId(): string

      The current invocation id.

      Returns string

    • get sessionId(): string

      The ID of the current session.

      Returns string

    • get userContent(): Content | undefined

      The user content that started this invocation.

      Returns Content | undefined

    • get userId(): string

      The user ID of the current session.

      Returns string

    Methods

    • Lists the filenames of the artifacts attached to the current session.

      Returns Promise<string[]>

      A promise that resolves to a list of artifact filenames.

    • Loads an artifact attached to the current session.

      Parameters

      • filename: string

        The filename of the artifact.

      • Optionalversion: number

        The version of the artifact. If not provided, the latest version will be used.

      Returns Promise<Part | undefined>

      A promise that resolves to the loaded artifact.

    • Requests confirmation for the current tool call.

      Parameters

      • __namedParameters: { hint?: string; payload?: unknown }

      Returns void

    • Saves an artifact attached to the current session.

      Parameters

      • filename: string

        The filename of the artifact.

      • artifact: Part

        The artifact to save.

      Returns Promise<number>

      A promise that resolves to the version of the saved artifact.

    • Searches the memory of the current user.

      Parameters

      • query: string

        The query to search memory for.

      Returns Promise<SearchMemoryResponse>

      A promise that resolves to SearchMemoryResponse containing the matching memories.