---
type: email
from: Hassan Abu Alhaj <notifications@github.com>
subject: Re: [openai/openai-agents-python] Feat: Add AdvancedSQLiteSession

 with conversation branching & usage tracking (PR #1662)
received: 2026-03-06 07:30:43
date_header: Sat, 13 Sep 2025 10:00:04 -0700
priority: normal
status: awaiting_approval
uid: 30346
---

## Email Content

**From:** Hassan Abu Alhaj <notifications@github.com>
**Subject:** Re: [openai/openai-agents-python] Feat: Add AdvancedSQLiteSession

 with conversation branching & usage tracking (PR #1662)
**Date:** Sat, 13 Sep 2025 10:00:04 -0700

### Body (preview)

habema left a comment (openai/openai-agents-python#1662)



I ran into a bug in my implementation of `reactivate_from_turn()`, which uncovered deeper issues. I replaced the broken soft deletion approach with actual branch-based conversation management. 



**Key changes:**

- Added `branch_id` and `branch_turn_number` columns to schema, removed `is_active`/`deactivated_at` 

- Replaced `deactivate_from_turn()`/`reactivate_from_turn()` with `create_branch_from_turn()` that properly copies conversation history

- Fixed the original bug where reactivating would affect both original and new branches

- Added proper branch switching with `switch_to_branch()` and `list_branches()`

- Updated unique constraints to include `branch_id` so turn numbers can overlap between branches



Now each branch is truly isolated - no more weird cross-branch contamination when doing operations.



I understand this might require some extensive review, so take your time.



-- 

Reply to this email directly or view it on GitHub:

https://github.com/openai/openai-agents-python/pull/1662#issuecomment-3288635704

You are receiving this because you are subscribed to this thread.



Message ID: <openai/openai-agents-python/pull/1662/c3288635704@github.com>

---

## Suggested Actions
- [ ] Reply
- [ ] Archive
- [ ] Escalate
