Anyone knows this issue ? The last_update_time provided in the session object '2026-02-02 16:56:28' is earlier than the update_time in the storage_session '2026-02-02 16:57:38'. Please check if it is a stale session. #4352
Replies: 1 comment
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: This error is a safeguard in ADK's session management. It happens when you try to update a session using an outdated session object, which can occur in concurrent environments like a web server. To fix this, you should reload the session from the session service right before you need to make an update, instead of reusing an older session object. Hello! This What Causes the "Stale Session" Error?The ADK The error you're seeing occurs because of a sequence like this:
This is a crucial safeguard to prevent data loss and corruption in your conversation history. How to Fix ItThe solution is to ensure your code is always working with the most recent version of the session. Guideline: Reload the session from the Instead of holding onto a Example Pattern: Incorrect (may lead to error): # 1. Get session at the start of a long process
session = await session_service.get_session(app_name="app", user_id="user", session_id="123")
# ... some other process might update the session in the DB here ...
# 2. Try to append an event using the old session object
await session_service.append_event(session, new_event) # <-- This can raise the ValueErrorCorrect: # In each independent operation, get the latest session first
async def handle_new_message(message_text):
# 1. Get the LATEST session from storage
session = await session_service.get_session(app_name="app", user_id="user", session_id="123")
# 2. Create and append the new event
new_event = Event(...)
await session_service.append_event(session, new_event) # <-- This is safeSince you are using the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Getting this error:
22:19:02.496
raise ValueError(
22:19:02.496
ValueError: The last_update_time provided in the session object '2026-02-02 16:48:14' is earlier than the update_time in the storage_session '2026-02-02 16:48:51'. Please check if it is a stale session.
22:27:40.591
ERROR:google_adk.google.adk.cli.adk_web_server:Error in event_generator: The last_update_time provided in the session object '2026-02-02 16:56:28' is earlier than the update_time in the storage_session '2026-02-02 16:57:38'. Please check if it is a stale session.
22:27:40.591
raise ValueError(
22:27:40.591
ValueError: The last_update_time provided in the session object '2026-02-02 16:56:28' is earlier than the update_time in the storage_session '2026-02-02 16:57:38'. Please check if it is a stale session.
22:29:22.072
ERROR:google_adk.google.adk.cli.adk_web_server:Error in event_generator: The last_update_time provided in the session object '2026-02-02 16:57:38' is earlier than the update_time in the storage_session '2026-02-02 16:59:04'. Please check if it is a stale session.
22:29:22.073
raise ValueError(
22:29:22.073
ValueError: The last_update_time provided in the session object '2026-02-02 16:57:38' is earlier than the update_time in the storage_session '2026-02-02 16:59:04'. Please check if it is a stale session.
22:30:35.897
ERROR:google_adk.google.adk.cli.adk_web_server:Error in event_generator: The last_update_time provided in the session object '2026-02-02 16:59:04' is earlier than the update_time in the storage_session '2026-02-02 17:00:31'. Please check if it is a stale session.
22:30:35.897
raise ValueError(
22:30:35.897
ValueError: The last_update_time provided in the session object '2026-02-02 16:59:04' is earlier than the update_time in the storage_session '2026-02-02 17:00:31'. Please check if it is a stale session.
Beta Was this translation helpful? Give feedback.
All reactions