Skip to content

Commit 474b0b7

Browse files
committed
rename to AdvancedSQLiteSession
1 parent 86b069a commit 474b0b7

File tree

5 files changed

+43
-37
lines changed

5 files changed

+43
-37
lines changed

examples/memory/advanced_structured_session_example.py renamed to examples/memory/advanced_session_advanced_example.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Advanced example demonstrating conversation branching with StructuredSQLiteSession.
2+
Advanced example demonstrating conversation branching with AdvancedSQLiteSession.
33
44
This example shows how to use soft deletion for conversation editing/branching,
55
allowing you to "undo" parts of a conversation and continue from any point.
@@ -8,7 +8,7 @@
88
import asyncio
99

1010
from agents import Agent, Runner, function_tool
11-
from agents.extensions.memory import StructuredSQLiteSession
11+
from agents.extensions.memory import AdvancedSQLiteSession
1212

1313

1414
@function_tool
@@ -26,10 +26,10 @@ async def main():
2626
tools=[get_weather],
2727
)
2828

29-
# Create a structured session instance
30-
session = StructuredSQLiteSession("conversation_advanced")
29+
# Create a advanced session instance
30+
session = AdvancedSQLiteSession("conversation_advanced")
3131

32-
print("=== Advanced Structured Session: Conversation Branching ===")
32+
print("=== Advanced Session: Conversation Branching ===")
3333
print("This example demonstrates conversation editing and branching.\n")
3434

3535
# Build initial conversation

examples/memory/basic_structured_session_example.py renamed to examples/memory/advanced_session_basic_example.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"""
2-
Basic example demonstrating structured session memory functionality.
2+
Basic example demonstrating advanced session memory functionality.
33
4-
This example shows how to use StructuredSQLiteSession for conversation tracking
4+
This example shows how to use AdvancedSQLiteSession for conversation tracking
55
with usage statistics and turn-based organization.
66
"""
77

88
import asyncio
99

1010
from agents import Agent, Runner, function_tool
11-
from agents.extensions.memory import StructuredSQLiteSession
11+
from agents.extensions.memory import AdvancedSQLiteSession
1212

1313

1414
@function_tool
@@ -26,10 +26,10 @@ async def main():
2626
tools=[get_weather],
2727
)
2828

29-
# Create a structured session instance
30-
session = StructuredSQLiteSession("conversation_basic")
29+
# Create a advanced session instance
30+
session = AdvancedSQLiteSession("conversation_basic")
3131

32-
print("=== Basic Structured Session Example ===")
32+
print("=== Basic Advanced Session Example ===")
3333
print("The agent will remember previous messages with structured tracking.\n")
3434

3535
# First turn

src/agents/extensions/memory/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
"""
99
from __future__ import annotations
1010

11+
from .advanced_sqlite_session import AdvancedSQLiteSession # noqa: F401
1112
from .sqlalchemy_session import SQLAlchemySession # noqa: F401
12-
from .structured_sqlite_session import StructuredSQLiteSession # noqa: F401
1313

1414
__all__: list[str] = [
1515
"SQLAlchemySession",
16-
"StructuredSQLiteSession",
16+
"AdvancedSQLiteSession",
1717
]

src/agents/extensions/memory/structured_sqlite_session.py renamed to src/agents/extensions/memory/advanced_sqlite_session.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@
1313
from ...memory import SQLiteSession
1414

1515

16-
class StructuredSQLiteSession(SQLiteSession):
17-
"""SQLite session with simple structured metadata and soft deletion."""
16+
class AdvancedSQLiteSession(SQLiteSession):
17+
"""Enhanced SQLite session with turn tracking, soft deletion, and usage analytics.
18+
19+
Features:
20+
- Turn-based conversation management with soft delete/reactivate
21+
- Detailed usage tracking per turn with token breakdowns
22+
- Message structure metadata and tool usage statistics
23+
"""
1824

1925
ACTIVE = 1 # Message is active and visible in conversation
2026
INACTIVE = 0 # Message is soft-deleted (hidden but preserved)

tests/extensions/memory/test_structured_sqlite_session.py renamed to tests/extensions/memory/test_advanced_sqlite_session.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Tests for StructuredSQLiteSession functionality."""
1+
"""Tests for AdvancedSQLiteSession functionality."""
22

33
import tempfile
44
from pathlib import Path
@@ -10,7 +10,7 @@
1010
from openai.types.responses.response_usage import InputTokensDetails, OutputTokensDetails
1111

1212
from agents import Agent, Runner, TResponseInputItem, function_tool
13-
from agents.extensions.memory import StructuredSQLiteSession
13+
from agents.extensions.memory import AdvancedSQLiteSession
1414
from agents.result import RunResult
1515
from agents.run_context import RunContextWrapper
1616
from 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

Comments
 (0)