Set Branch • AI Agent SDK

set_branch: Set current branch context for parallel execution tracking.

set_branch

Method

</div>

This is a method of the ContextTraceEmitter class in the context_events module.

Set current branch context for parallel execution tracking.

All subsequent events emitted from the current context (thread or asyncio task) include this branch_id until cleared. Concurrent branches each run in their own copied context, so they cannot overwrite each other’s branch.

Signature

python
def set_branch(branch_id: str) -> None

Parameters

ParamField str

Identifier for the parallel branch (e.g., ‘parallel_0’, ‘loop_5’)

Source

View on GitHub

praisonaiagents/trace/context_events.py at line 694