Skip to content

Commit 8b6af5d

Browse files
committed
move session creation to runner level
1 parent 62fa4e5 commit 8b6af5d

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/google/adk/runners.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,9 @@ async def _run_with_trace(
454454
app_name=self.app_name, user_id=user_id, session_id=session_id
455455
)
456456
if not session:
457-
message = self._format_session_not_found_message(session_id)
458-
raise ValueError(message)
457+
session = await self.session_service.create_session(
458+
app_name=self.app_name, user_id=user_id, session_id=session_id
459+
)
459460
if not invocation_id and not new_message:
460461
raise ValueError(
461462
'Running an agent requires either a new_message or an '

src/google/adk/sessions/database_session_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,8 @@ async def append_event(self, session: Session, event: Event) -> Event:
436436
if storage_session.update_timestamp_tz > session.last_update_time:
437437
raise ValueError(
438438
"The last_update_time provided in the session object"
439-
f" {datetime.fromtimestamp(session.last_update_time):'%Y-%m-%d %H:%M:%S'} is"
440-
" earlier than the update_time in the storage_session"
439+
f" {datetime.fromtimestamp(session.last_update_time):'%Y-%m-%d %H:%M:%S'}"
440+
" is earlier than the update_time in the storage_session"
441441
f" {datetime.fromtimestamp(storage_session.update_timestamp_tz):'%Y-%m-%d %H:%M:%S'}."
442442
" Please check if it is a stale session."
443443
)

0 commit comments

Comments
 (0)