@@ -187,6 +187,7 @@ async def _add_structure_metadata(self, items: list[TResponseInputItem]) -> None
187
187
188
188
def _add_structure_sync ():
189
189
conn = self ._get_connection ()
190
+ # TODO: Refactor SQLiteSession to use asyncio.Lock instead of threading.Lock and update this code # noqa: E501
190
191
with self ._lock if self ._is_memory_db else threading .Lock ():
191
192
# Get the IDs of messages we just inserted, in order
192
193
with closing (conn .cursor ()) as cursor :
@@ -290,6 +291,7 @@ async def _cleanup_orphaned_messages(self) -> None:
290
291
291
292
def _cleanup_sync ():
292
293
conn = self ._get_connection ()
294
+ # TODO: Refactor SQLiteSession to use asyncio.Lock instead of threading.Lock and update this code # noqa: E501
293
295
with self ._lock if self ._is_memory_db else threading .Lock ():
294
296
with closing (conn .cursor ()) as cursor :
295
297
# Find messages without structure metadata
@@ -381,6 +383,7 @@ async def get_items(
381
383
# Get all items for this branch
382
384
def _get_all_items_sync ():
383
385
conn = self ._get_connection ()
386
+ # TODO: Refactor SQLiteSession to use asyncio.Lock instead of threading.Lock and update this code # noqa: E501
384
387
with self ._lock if self ._is_memory_db else threading .Lock ():
385
388
with closing (conn .cursor ()) as cursor :
386
389
if limit is None :
@@ -424,6 +427,7 @@ def _get_all_items_sync():
424
427
425
428
def _get_items_sync ():
426
429
conn = self ._get_connection ()
430
+ # TODO: Refactor SQLiteSession to use asyncio.Lock instead of threading.Lock and update this code # noqa: E501
427
431
with self ._lock if self ._is_memory_db else threading .Lock ():
428
432
with closing (conn .cursor ()) as cursor :
429
433
# Get message IDs in correct order for this branch
@@ -471,6 +475,7 @@ async def _copy_messages_to_new_branch(self, new_branch_id: str, from_turn_numbe
471
475
472
476
def _copy_sync ():
473
477
conn = self ._get_connection ()
478
+ # TODO: Refactor SQLiteSession to use asyncio.Lock instead of threading.Lock and update this code # noqa: E501
474
479
with self ._lock if self ._is_memory_db else threading .Lock ():
475
480
with closing (conn .cursor ()) as cursor :
476
481
# Get all messages before the branch point
@@ -603,7 +608,7 @@ def _validate_turn():
603
608
old_branch = self ._current_branch_id
604
609
self ._current_branch_id = branch_name
605
610
606
- self ._logger .info (
611
+ self ._logger .debug (
607
612
f"Created branch '{ branch_name } ' from turn { turn_number } ('{ turn_content } ') in '{ old_branch } '" # noqa: E501
608
613
)
609
614
return branch_name
@@ -671,6 +676,7 @@ async def delete_branch(self, branch_id: str, force: bool = False) -> None:
671
676
672
677
def _delete_sync ():
673
678
conn = self ._get_connection ()
679
+ # TODO: Refactor SQLiteSession to use asyncio.Lock instead of threading.Lock and update this code # noqa: E501
674
680
with self ._lock if self ._is_memory_db else threading .Lock ():
675
681
with closing (conn .cursor ()) as cursor :
676
682
# First verify the branch exists
@@ -748,7 +754,8 @@ def _get_turns_sync():
748
754
FROM message_structure ms
749
755
JOIN agent_messages am ON ms.message_id = am.id
750
756
WHERE ms.session_id = ? AND ms.branch_id = ?
751
- AND ms.message_type = 'user' ORDER BY ms.branch_turn_number
757
+ AND ms.message_type = 'user'
758
+ ORDER BY ms.branch_turn_number
752
759
""" ,
753
760
(self .session_id , branch_id ),
754
761
)
@@ -801,7 +808,8 @@ def _search_sync():
801
808
FROM message_structure ms
802
809
JOIN agent_messages am ON ms.message_id = am.id
803
810
WHERE ms.session_id = ? AND ms.branch_id = ?
804
- AND ms.message_type = 'user' AND am.message_data LIKE ?
811
+ AND ms.message_type = 'user'
812
+ AND am.message_data LIKE ?
805
813
ORDER BY ms.branch_turn_number
806
814
""" ,
807
815
(self .session_id , branch_id , f"%{ search_term } %" ),
@@ -904,6 +912,7 @@ async def _update_turn_usage_internal(self, user_turn_number: int, usage_data: U
904
912
905
913
def _update_sync ():
906
914
conn = self ._get_connection ()
915
+ # TODO: Refactor SQLiteSession to use asyncio.Lock instead of threading.Lock and update this code # noqa: E501
907
916
with self ._lock if self ._is_memory_db else threading .Lock ():
908
917
# Serialize token details as JSON
909
918
input_details_json = None
@@ -961,6 +970,7 @@ async def get_session_usage(self, branch_id: str | None = None) -> dict[str, int
961
970
962
971
def _get_usage_sync ():
963
972
conn = self ._get_connection ()
973
+ # TODO: Refactor SQLiteSession to use asyncio.Lock instead of threading.Lock and update this code # noqa: E501
964
974
with self ._lock if self ._is_memory_db else threading .Lock ():
965
975
if branch_id :
966
976
# Branch-specific usage
0 commit comments