> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Set Branch • AI Agent SDK

> set_branch: Set current branch context for parallel execution tracking.

# set\_branch

Method

> This is a method of the [**ContextTraceEmitter**](https://praison.ai/docs/sdk/reference/praisonaiagents/classes/ContextTraceEmitter.md) class in the [**context\_events**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/context_events.md) 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 theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def set_branch(branch_id: str) -> None
```

## Parameters

**branch\_id** `str` *required*

Identifier for the parallel branch (e.g., 'parallel\_0', 'loop\_5')

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/trace/context_events.py#L694)
>
> `praisonaiagents/trace/context_events.py` at line 694


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.