def _create_branch_ctx_for_sub_agent(
    agent: BaseAgent,
    sub_agent: BaseAgent,
    invocation_context: InvocationContext,
) -> InvocationContext:
  """Create isolated branch for every sub-agent."""
  invocation_context = invocation_context.model_copy()
  branch_suffix = f"{agent.name}.{sub_agent.name}"
  invocation_context.branch = (
      f"{invocation_context.branch}.{branch_suffix}"
      if invocation_context.branch
      else branch_suffix
  )
  return invocation_context
Create isolated branch for every sub-agent.
src/google/adk/agents/parallel_agent.py