Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ if __name__ == "__main__":
You can implement your own session memory by creating a class that follows the [`Session`][agents.memory.session.Session] protocol:

```python
from agents.memory import Session
from agents.items import TResponseInputItem
from typing import List

class MyCustomSession:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class should inherit SessionABC

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the requested change but noticed that the SessionABC docstring says it should be inherited only for internal implementations. Should we also update this docstring?

class SessionABC(ABC):
"""Abstract base class for session implementations.
Session stores conversation history for a specific session, allowing
agents to maintain context without requiring explicit manual memory management.
This ABC is intended for internal use and as a base class for concrete implementations.
Third-party libraries should implement the Session protocol instead.
"""

Expand All @@ -237,17 +237,17 @@ class MyCustomSession:
self.session_id = session_id
# Your initialization here

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

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

async def pop_item(self) -> dict | None:
async def pop_item(self) -> TResponseInputItem | None:
"""Remove and return the most recent item from this session."""
# Your implementation here
pass
Expand Down