BaseAgent

abstract class BaseAgent(val name: String, val description: String = "", val subAgents: List<BaseAgent> = emptyList(), val beforeAgentCallbacks: List<BeforeAgentCallback> = emptyList(), val afterAgentCallbacks: List<AfterAgentCallback> = emptyList(), val disallowTransferToParent: Boolean = false, val disallowTransferToPeers: Boolean = false)

Base class for all agents.

Implements the Template Method pattern to handle the agent execution lifecycle, including context creation, tracing, and callbacks. Subclasses must implement runAsyncImpl to define specific behavior.

Inheritors

Constructors

Link copied to clipboard
constructor(name: String, description: String = "", subAgents: List<BaseAgent> = emptyList(), beforeAgentCallbacks: List<BeforeAgentCallback> = emptyList(), afterAgentCallbacks: List<AfterAgentCallback> = emptyList(), disallowTransferToParent: Boolean = false, disallowTransferToPeers: Boolean = false)

Properties

Link copied to clipboard

List of callbacks to run after the agent executes.

Link copied to clipboard

List of callbacks to run before the agent executes.

Link copied to clipboard

The description of the agent.

Link copied to clipboard

When true, the framework will not route the next user turn back to this agent after the parent transfers control to it; instead the next turn falls back to the root agent. Set this on utility sub-agents the parent calls and returns from (translators, summarizers, classifiers). Leave at the default false for sub-agents that should keep handling follow-up turns directly (e.g. billing, support).

Link copied to clipboard

When true, prevents this agent from transferring sideways to a peer agent under the same parent. Typically set together with disallowTransferToParent on one-shot utility agents. Violations are surfaced by the runner as IllegalArgumentException.

Link copied to clipboard

The name of the agent.

Link copied to clipboard

List of sub-agents.

Functions

Link copied to clipboard
fun BaseAgent.findAgent(targetName: String): BaseAgent?

Finds an agent with the given name in this agent's subtree (including itself).

Link copied to clipboard
fun runAsync(parentContext: InvocationContext): Flow<Event>

Public entry point for executing the agent asynchronously (text-based).