1- """Tests for StructuredSQLiteSession functionality."""
1+ """Tests for AdvancedSQLiteSession functionality."""
22
33import tempfile
44from pathlib import Path
1010from openai .types .responses .response_usage import InputTokensDetails , OutputTokensDetails
1111
1212from agents import Agent , Runner , TResponseInputItem , function_tool
13- from agents .extensions .memory import StructuredSQLiteSession
13+ from agents .extensions .memory import AdvancedSQLiteSession
1414from agents .result import RunResult
1515from agents .run_context import RunContextWrapper
1616from agents .usage import Usage
@@ -77,12 +77,12 @@ def create_mock_run_result(
7777 )
7878
7979
80- async def test_structured_session_basic_functionality (agent : Agent ):
81- """Test basic StructuredSQLiteSession functionality."""
80+ async def test_advanced_session_basic_functionality (agent : Agent ):
81+ """Test basic AdvancedSQLiteSession functionality."""
8282 with tempfile .TemporaryDirectory () as temp_dir :
83- db_path = Path (temp_dir ) / "test_structured .db"
84- session_id = "structured_test "
85- session = StructuredSQLiteSession (session_id , db_path )
83+ db_path = Path (temp_dir ) / "test_advanced .db"
84+ session_id = "advanced_test "
85+ session = AdvancedSQLiteSession (session_id , db_path )
8686
8787 # Test basic session operations work
8888 items : list [TResponseInputItem ] = [
@@ -105,7 +105,7 @@ async def test_message_structure_tracking(agent: Agent):
105105 with tempfile .TemporaryDirectory () as temp_dir :
106106 db_path = Path (temp_dir ) / "test_structure.db"
107107 session_id = "structure_test"
108- session = StructuredSQLiteSession (session_id , db_path )
108+ session = AdvancedSQLiteSession (session_id , db_path )
109109
110110 # Add various types of messages
111111 items : list [TResponseInputItem ] = [
@@ -140,7 +140,7 @@ async def test_tool_usage_tracking(agent: Agent):
140140 with tempfile .TemporaryDirectory () as temp_dir :
141141 db_path = Path (temp_dir ) / "test_tools.db"
142142 session_id = "tools_test"
143- session = StructuredSQLiteSession (session_id , db_path )
143+ session = AdvancedSQLiteSession (session_id , db_path )
144144
145145 # Add items with tool calls
146146 items : list [TResponseInputItem ] = [
@@ -169,7 +169,7 @@ async def test_soft_deletion_functionality(agent: Agent):
169169 with tempfile .TemporaryDirectory () as temp_dir :
170170 db_path = Path (temp_dir ) / "test_deletion.db"
171171 session_id = "deletion_test"
172- session = StructuredSQLiteSession (session_id , db_path )
172+ session = AdvancedSQLiteSession (session_id , db_path )
173173
174174 # Add multiple turns
175175 turn_1_items : list [TResponseInputItem ] = [
@@ -224,7 +224,7 @@ async def test_usage_tracking_storage(agent: Agent, usage_data: Usage):
224224 with tempfile .TemporaryDirectory () as temp_dir :
225225 db_path = Path (temp_dir ) / "test_usage.db"
226226 session_id = "usage_test"
227- session = StructuredSQLiteSession (session_id , db_path )
227+ session = AdvancedSQLiteSession (session_id , db_path )
228228
229229 # Simulate adding items for turn 1 to increment turn counter
230230 await session .add_items ([{"role" : "user" , "content" : "First turn" }])
@@ -285,9 +285,9 @@ async def test_runner_integration_with_usage_tracking(agent: Agent):
285285 with tempfile .TemporaryDirectory () as temp_dir :
286286 db_path = Path (temp_dir ) / "test_integration.db"
287287 session_id = "integration_test"
288- session = StructuredSQLiteSession (session_id , db_path )
288+ session = AdvancedSQLiteSession (session_id , db_path )
289289
290- async def store_session_usage (result : Any , session : StructuredSQLiteSession ):
290+ async def store_session_usage (result : Any , session : AdvancedSQLiteSession ):
291291 """Helper function to store usage after runner completes."""
292292 try :
293293 await session .store_run_usage (result )
@@ -335,7 +335,7 @@ async def test_sequence_ordering():
335335 with tempfile .TemporaryDirectory () as temp_dir :
336336 db_path = Path (temp_dir ) / "test_sequence.db"
337337 session_id = "sequence_test"
338- session = StructuredSQLiteSession (session_id , db_path )
338+ session = AdvancedSQLiteSession (session_id , db_path )
339339
340340 # Add multiple items quickly to test sequence ordering
341341 items : list [TResponseInputItem ] = [
@@ -362,7 +362,7 @@ async def test_conversation_structure_with_multiple_turns():
362362 with tempfile .TemporaryDirectory () as temp_dir :
363363 db_path = Path (temp_dir ) / "test_multi_turn.db"
364364 session_id = "multi_turn_test"
365- session = StructuredSQLiteSession (session_id , db_path )
365+ session = AdvancedSQLiteSession (session_id , db_path )
366366
367367 # Turn 1
368368 turn_1 : list [TResponseInputItem ] = [
@@ -415,7 +415,7 @@ async def test_empty_session_operations():
415415 with tempfile .TemporaryDirectory () as temp_dir :
416416 db_path = Path (temp_dir ) / "test_empty.db"
417417 session_id = "empty_test"
418- session = StructuredSQLiteSession (session_id , db_path )
418+ session = AdvancedSQLiteSession (session_id , db_path )
419419
420420 # Test getting items from empty session
421421 items = await session .get_items ()
@@ -445,7 +445,7 @@ async def test_json_serialization_edge_cases(usage_data: Usage):
445445 with tempfile .TemporaryDirectory () as temp_dir :
446446 db_path = Path (temp_dir ) / "test_json.db"
447447 session_id = "json_test"
448- session = StructuredSQLiteSession (session_id , db_path )
448+ session = AdvancedSQLiteSession (session_id , db_path )
449449
450450 # Test with normal usage data (need to add user message first to create turn)
451451 await session .add_items ([{"role" : "user" , "content" : "First test" }])
@@ -488,8 +488,8 @@ async def test_session_isolation():
488488 with tempfile .TemporaryDirectory () as temp_dir :
489489 db_path = Path (temp_dir ) / "test_isolation.db"
490490
491- session1 = StructuredSQLiteSession ("session_1" , db_path )
492- session2 = StructuredSQLiteSession ("session_2" , db_path )
491+ session1 = AdvancedSQLiteSession ("session_1" , db_path )
492+ session2 = AdvancedSQLiteSession ("session_2" , db_path )
493493
494494 # Add data to session 1
495495 await session1 .add_items ([{"role" : "user" , "content" : "Session 1 message" }])
@@ -522,7 +522,7 @@ async def test_error_handling_in_usage_tracking(usage_data: Usage):
522522 with tempfile .TemporaryDirectory () as temp_dir :
523523 db_path = Path (temp_dir ) / "test_errors.db"
524524 session_id = "error_test"
525- session = StructuredSQLiteSession (session_id , db_path )
525+ session = AdvancedSQLiteSession (session_id , db_path )
526526
527527 # Test normal operation
528528 run_result = create_mock_run_result (usage_data )
@@ -540,7 +540,7 @@ async def test_tool_name_extraction():
540540 with tempfile .TemporaryDirectory () as temp_dir :
541541 db_path = Path (temp_dir ) / "test_tool_names.db"
542542 session_id = "tool_names_test"
543- session = StructuredSQLiteSession (session_id , db_path )
543+ session = AdvancedSQLiteSession (session_id , db_path )
544544
545545 # Add items with different ways of specifying tool names
546546 items : list [TResponseInputItem ] = [
@@ -569,7 +569,7 @@ async def test_tool_execution_integration(agent: Agent):
569569 with tempfile .TemporaryDirectory () as temp_dir :
570570 db_path = Path (temp_dir ) / "test_tool_integration.db"
571571 session_id = "tool_integration_test"
572- session = StructuredSQLiteSession (session_id , db_path )
572+ session = AdvancedSQLiteSession (session_id , db_path )
573573
574574 # Set up the fake model to trigger a tool call
575575 fake_model = cast (FakeModel , agent .model )
0 commit comments