Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/google/adk/sessions/base_session_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GetSessionConfig(BaseModel):
with timestamp >= the given time.
"""

num_recent_events: Optional[int] = None
num_recent_events: Optional[int] = Field(default=None, ge=0)
after_timestamp: Optional[float] = None


Expand Down
6 changes: 6 additions & 0 deletions tests/unittests/sessions/test_session_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
from sqlalchemy.pool import StaticPool


def test_get_session_config_rejects_negative_num_recent_events():
"""A negative recent-event limit is rejected at configuration time."""
with pytest.raises(ValueError, match='greater than or equal to 0'):
GetSessionConfig(num_recent_events=-1)


class SessionServiceType(enum.Enum):
IN_MEMORY = 'IN_MEMORY'
IN_MEMORY_WITH_LIGHT_COPY_ENABLED = 'IN_MEMORY_WITH_LIGHT_COPY_ENABLED'
Expand Down