Skip to content

Commit 646c618

Browse files
Docs: Improve example for custom Session class implementation. (#1582)
1 parent 86e26e9 commit 646c618

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

docs/sessions.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,27 +227,28 @@ if __name__ == "__main__":
227227
You can implement your own session memory by creating a class that follows the [`Session`][agents.memory.session.Session] protocol:
228228

229229
```python
230-
from agents.memory import Session
230+
from agents.memory.session import SessionABC
231+
from agents.items import TResponseInputItem
231232
from typing import List
232233

233-
class MyCustomSession:
234+
class MyCustomSession(SessionABC):
234235
"""Custom session implementation following the Session protocol."""
235236

236237
def __init__(self, session_id: str):
237238
self.session_id = session_id
238239
# Your initialization here
239240

240-
async def get_items(self, limit: int | None = None) -> List[dict]:
241+
async def get_items(self, limit: int | None = None) -> List[TResponseInputItem]:
241242
"""Retrieve conversation history for this session."""
242243
# Your implementation here
243244
pass
244245

245-
async def add_items(self, items: List[dict]) -> None:
246+
async def add_items(self, items: List[TResponseInputItem]) -> None:
246247
"""Store new items for this session."""
247248
# Your implementation here
248249
pass
249250

250-
async def pop_item(self) -> dict | None:
251+
async def pop_item(self) -> TResponseInputItem | None:
251252
"""Remove and return the most recent item from this session."""
252253
# Your implementation here
253254
pass

0 commit comments

Comments
 (0)