# Class BaseAgent`Abstract`

Base class for all agents in Agent Development Kit.

#### Hierarchy (View Summary)

- BaseAgent
  - LlmAgent
  - LoopAgent
  - ParallelAgent
  - SequentialAgent

- Defined in agents/base_agent.ts:74

## Constructors

### constructor

- new BaseAgent(config: BaseAgentConfig): BaseAgent

  #### Parameters

  - config: BaseAgentConfig

  #### Returns BaseAgent

  - Defined in agents/base_agent.ts:149

## Properties

### `Readonly`[BASE_AGENT_SIGNATURE_SYMBOL]

"[BASE_AGENT_SIGNATURE_SYMBOL]": true

A unique symbol to identify ADK agent classes.

- Defined in agents/base_agent.ts:78

### `Readonly` afterAgentCallback

afterAgentCallback: SingleAgentCallback[]

Callback or list of callbacks to be invoked after the agent run.

When a list of callbacks is provided, the callbacks will be called in the order they are listed until a callback does not return undefined.

#### Param: callbackContext:

MUST be named 'callbackContext' (enforced).

#### Returns

Content: The content to return to the user. When the content is present, the provided content will be used as agent response and appended to event history as agent response.

- Defined in agents/base_agent.ts:147

### `Readonly` beforeAgentCallback

beforeAgentCallback: SingleAgentCallback[]

Callback or list of callbacks to be invoked before the agent run.

When a list of callbacks is provided, the callbacks will be called in the order they are listed until a callback does not return undefined.

#### Param: callbackContext:

MUST be named 'callbackContext' (enforced).

#### Returns

Content: The content to return to the user. When the content is present, the agent run will be skipped and the provided content will be returned to user.

- Defined in agents/base_agent.ts:133

### `Optional` `Readonly` description

description?: string

Description about the agent's capability.

The model uses this to determine whether to delegate control to the agent. One-line description is enough and preferred.

- Defined in agents/base_agent.ts:93

### `Readonly` name

name: string

The agent's name. Agent name must be a JS identifier and unique within the agent tree. Agent name cannot be "user", since it's reserved for end-user's input.

- Defined in agents/base_agent.ts:85

### `Optional` parentAgent

parentAgent?: BaseAgent

The parent agent of this agent.

Note that an agent can ONLY be added as sub-agent once.

If you want to add one agent twice as sub-agent, consider to create two agent instances with identical config, but with different name and add them to the agent tree.

The parent agent is the agent that created this agent.

- Defined in agents/base_agent.ts:114

### `Readonly` subAgents

subAgents: BaseAgent[]

The sub-agents of this agent.

- Defined in agents/base_agent.ts:119

## Accessors

### rootAgent

- get rootAgent(): BaseAgent

  Root agent of this agent. Computed dynamically by traversing up the parent chain.

  #### Returns BaseAgent

  - Defined in agents/base_agent.ts:99

## Methods

### `Protected` createInvocationContext

- createInvocationContext(parentContext: InvocationContext): InvocationContext

  Creates an invocation context for this agent.

  #### Parameters

  - parentContext: InvocationContext

    The invocation context of the parent agent.

  #### Returns InvocationContext

  The invocation context for this agent.

  - Defined in agents/base_agent.ts:297

### findAgent

- findAgent(name: string): BaseAgent | undefined

  Finds the agent with the given name in this agent and its descendants.

  #### Parameters

  - name: string

    The name of the agent to find.

  #### Returns BaseAgent | undefined

  The agent with the given name, or undefined if not found.

  - Defined in agents/base_agent.ts:266

### findSubAgent

- findSubAgent(name: string): BaseAgent | undefined

  Finds the agent with the given name in this agent's descendants.

  #### Parameters

  - name: string

    The name of the agent to find.

  #### Returns BaseAgent | undefined

  The agent with the given name, or undefined if not found.

  - Defined in agents/base_agent.ts:280

### `Protected` handleAfterAgentCallback

- handleAfterAgentCallback(
  invocationContext: InvocationContext,
  ): Promise<Event | undefined>

  Runs the after agent callback if it exists.

  #### Parameters

  - invocationContext: InvocationContext

    The invocation context of the agent.

  #### Returns Promise<Event | undefined>

  The event to return to the user, or undefined if no event is generated.

  - Defined in agents/base_agent.ts:356

### `Protected` handleBeforeAgentCallback

- handleBeforeAgentCallback(
  invocationContext: InvocationContext,
  ): Promise<Event | undefined>

  Runs the before agent callback if it exists.

  #### Parameters

  - invocationContext: InvocationContext

    The invocation context of the agent.

  #### Returns Promise<Event | undefined>

  The event to return to the user, or undefined if no event is generated.

  - Defined in agents/base_agent.ts:313

### runAsync

- runAsync(parentContext: InvocationContext): AsyncGenerator<Event, void, void>

  Entry method to run an agent via text-based conversation.

  #### Parameters

  - parentContext: InvocationContext

    The invocation context of the parent agent.

  #### Returns AsyncGenerator<Event, void, void>

  An AsyncGenerator that yields the events generated by the agent.

  #### Yields

  The events generated by the agent.

  - Defined in agents/base_agent.ts:169

### `Protected` `Abstract` runAsyncImpl

- runAsyncImpl(context: InvocationContext): AsyncGenerator<Event, void, void>

  Core logic to run this agent via text-based conversation.

  #### Parameters

  - context: InvocationContext

    The invocation context of the agent.

  #### Returns AsyncGenerator<Event, void, void>

  An AsyncGenerator that yields the events generated by the agent.

  #### Yields

  The events generated by the agent.

  - Defined in agents/base_agent.ts:245

### runLive

- runLive(parentContext: InvocationContext): AsyncGenerator<Event, void, void>

  Entry method to run an agent via video/audio-based conversation.

  #### Parameters

  - parentContext: InvocationContext

    The invocation context of the parent agent.

  #### Returns AsyncGenerator<Event, void, void>

  An AsyncGenerator that yields the events generated by the agent.

  #### Yields

  The events generated by the agent.

  - Defined in agents/base_agent.ts:219

### `Protected` `Abstract` runLiveImpl

- runLiveImpl(context: InvocationContext): AsyncGenerator<Event, void, void>

  Core logic to run this agent via video/audio-based conversation.

  #### Parameters

  - context: InvocationContext

    The invocation context of the agent.

  #### Returns AsyncGenerator<Event, void, void>

  An AsyncGenerator that yields the events generated by the agent.

  #### Yields

  The events generated by the agent.

  - Defined in agents/base_agent.ts:256