# ParallelAgent

class ParallelAgent(val name: String, val description: String = "", val subAgents: List<BaseAgent> = emptyList(), val beforeAgentCallbacks: List<BeforeAgentCallback> = emptyList(), val afterAgentCallbacks: List<AfterAgentCallback> = emptyList()) : BaseAgent

A shell agent that runs its sub-agents in parallel in an isolated manner.

This approach is beneficial for scenarios requiring multiple perspectives or attempts on a single task, such as:

- Running different algorithms simultaneously.

- Generating multiple responses for review by a subsequent evaluation agent.

## Constructors

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

## Properties

afterAgentCallbacks
Link copied to clipboard
val afterAgentCallbacks: List<AfterAgentCallback>

List of callbacks to run after the agent executes.

beforeAgentCallbacks
Link copied to clipboard
val beforeAgentCallbacks: List<BeforeAgentCallback>

List of callbacks to run before the agent executes.

description
Link copied to clipboard
open val description: String

The description of the agent.

disallowTransferToParent
Link copied to clipboard
val disallowTransferToParent: Boolean = false

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).

disallowTransferToPeers
Link copied to clipboard
val disallowTransferToPeers: Boolean = false

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`.

name
Link copied to clipboard
val name: String

The name of the agent.

subAgents
Link copied to clipboard
val subAgents: List<BaseAgent>

List of sub-agents.

## Functions

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

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

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

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