branch

Creates a new InvocationContext for a child agent, derived from this context. Appends the given agent's name to the branch path.

Use this only to isolate an agent's conversation history from its siblings (e.g. ParallelAgent); a plain agent entry or transfer should use forAgent so the child shares the parent's branch, matching Python ADK 1.x.

Return

The new InvocationContext.

Parameters

childAgent

The new agent for the branched context.


val branch: String? = null

The branch of the invocation context.

The format is like agent_1.agent_2.agent_3, where agent_1 is the parent of agent_2, and agent_2 is the parent of agent_3.

Branch is used when multiple sub-agents shouldn't see their peer agents' conversation history.