[Go to site: main page, start]

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

    Class Runner

    Orchestrates agent execution for a given application.

    The Runner manages the full lifecycle of an agent invocation: it loads the session, invokes plugin callbacks, runs the root agent, and yields the resulting events. Use InMemoryRunner for quick prototyping without external services.

    Example:

    const runner = new Runner({
    appName: 'my_app',
    agent: myAgent,
    sessionService: new InMemorySessionService(),
    });

    for await (const event of runner.runAsync({
    userId: 'user1',
    sessionId: 'session1',
    newMessage: {parts: [{text: 'Hello'}]},
    })) {
    console.log(event);
    }

    Hierarchy (View Summary)

    Constructors

    Properties

    "[RUNNER_SIGNATURE_SYMBOL]": true
    agent: BaseAgent
    appName: string
    artifactService?: BaseArtifactService
    credentialService?: BaseCredentialService
    memoryService?: BaseMemoryService
    pluginManager: PluginManager
    resumabilityConfig?: ResumabilityConfig
    sessionService: BaseSessionService

    Methods

    • Runs the agent with the given message, and returns an async generator of events.

      Parameters

      • params: {
            abortSignal?: AbortSignal;
            customMetadata?: Record<string, unknown>;
            newMessage: Content;
            runConfig?: RunConfig;
            sessionId: string;
            stateDelta?: Record<string, unknown>;
            userId: string;
        }
        • OptionalabortSignal?: AbortSignal
        • OptionalcustomMetadata?: Record<string, unknown>
        • newMessage: Content

          A new message to append to the session.

        • OptionalrunConfig?: RunConfig

          The run config for the agent.

        • sessionId: string

          The session ID of the session.

        • OptionalstateDelta?: Record<string, unknown>

          An optional state delta to apply to the session.

        • userId: string

          The user ID of the session.

      Returns AsyncGenerator<Event, void, undefined>

      The events generated by the agent.

    • Runs the agent with a new, ephemeral session.

      Parameters

      • params: {
            customMetadata?: Record<string, unknown>;
            newMessage: Content;
            runConfig?: RunConfig;
            stateDelta?: Record<string, unknown>;
            userId: string;
        }
        • OptionalcustomMetadata?: Record<string, unknown>
        • newMessage: Content

          A new message to append to the session.

        • OptionalrunConfig?: RunConfig

          The run config for the agent.

        • OptionalstateDelta?: Record<string, unknown>

          An optional state delta to apply to the session.

        • userId: string

          The user ID of the session.

      Returns AsyncGenerator<Event, void, undefined>

      The Events generated by the agent.