Back to Adk Python

BaseAgent

.agents/skills/adk-architecture/references/interfaces/base-agent.md

2.0.0b11.5 KB
Original Source

BaseAgent

BaseAgent is the base class for all agents in the ADK. Developers subclass BaseAgent to create custom agentic entities. It inherits from BaseNode and provides the core structure and lifecycle management for agents.

Core Contract for Subclasses

[!IMPORTANT] Since agents now extend BaseNode, the original run_async entrance method is considered deprecated. Developers should rely on the new run method from BaseNode and use _run_impl as the primary override point for custom logic.

When creating a custom agent by subclassing BaseAgent, you should focus on the following:

_run_impl (Preferred Override Point)

Core logic to run the agent as a workflow node.

Arguments:

  • ctx: Context, the node execution context.
  • node_input: Any, the input to the node.

Yields:

  • The results generated by the agent.

Legacy Methods (Deprecated for Node Execution)

The following methods were used for text and live conversations but are being superseded by the node-based execution model:

  • _run_async_impl: Core logic for text-based conversation.
  • _run_live_impl: Core logic for live conversation.

Key Attributes to Configure

  • name: The agent's name. Must be a valid Python identifier and unique within the agent tree. Cannot be "user".
  • description: A description of the agent's capability, used by the model for delegation choices.
  • sub_agents: A list of child agents to support hierarchical delegation.