How long can a live agent session remain open for? #63
Replies: 5 comments
-
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: Live agent sessions have time limits depending on the session type. Audio-only sessions are limited to 15 minutes, and audio-video sessions are limited to 2 minutes. The time a session remains open counts towards the free tier quota. Hello @xuanyang15, Thank you for your question. Here's the information you requested about live agent session duration and its relation to the free tier quota for Gemini Live. A live agent session can remain open for different durations depending on the type of session. For audio-only sessions without compression, the session is limited to 15 minutes. For audio-video sessions without compression, the limit is 2 minutes. If these limits are exceeded, the session will be terminated. [1] The time a live agent session remains open is a factor in the free tier for Gemini Live, as there are limits on session duration. The free tier for Gemini 1.5 Flash Live is also limited to 3 sessions. [2] I hope this information is helpful. Footnotes: |
Beta Was this translation helpful? Give feedback.
-
Does the ADK support using context window compression and session resumption to extend the active session for an unlimited amount of time? It's crucial the streaming tool remains active at all times, listening for events. Thank you! |
Beta Was this translation helpful? Give feedback.
-
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: While the ADK, through the Gemini API, supports context window compression and session resumption, it does not allow for an unlimited active session. Sessions have time limits and are not designed to remain active indefinitely. Hello @xuanyang15, Thank you for your follow-up question. While the Gemini API does support context window compression and session resumption, these features are not intended to extend the active session for an unlimited amount of time. Context Window Compression: Session Resumption: Therefore, a streaming tool that needs to remain active at all times listening for events cannot rely on a single, indefinitely open session. I hope this clarifies the capabilities and limitations of the session management features. Footnotes: |
Beta Was this translation helpful? Give feedback.
-
How to use context window compression and session resumption with ADK? Could you please provide a detailed example with ADK code? |
Beta Was this translation helpful? Give feedback.
-
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: The ADK facilitates session resumption through its Hello @xuanyang15, Here is an explanation and a code example of how to use session resumption with the ADK. Session Resumption with ADKSession resumption is a key feature of the ADK that allows you to continue a session after it has been interrupted, for example, due to a network issue or an application restart. This is managed by the
To use session resumption, you need to use a persistent session service like Here is a conceptual code example of how you might implement this: from adk.api import ADK
from adk.domain.session import Session, SessionService
from adk.domain.state import State
from adk.services.session_service import DatabaseSessionService
# Assume you have a database configuration
db_config = {...}
# Initialize the ADK with a persistent session service
adk = ADK(session_service_config=db_config, session_service=DatabaseSessionService)
# --- First run of the application ---
# Create a new session
session_id = "my-persistent-session"
@adk.prompt("Start a new session")
def start_session(session: Session, state: State):
state["message_count"] = 1
return f"New session started with ID: {session.session_id}. Message count: {state['message_count']}"
# Run the ADK
# runner = adk.run_command_line() # or adk.run_service()
# Assume we run the 'Start a new session' prompt
# The state {'message_count': 1} is saved to the database for session 'my-persistent-session'
# --- Application restarts ---
# --- Second run of the application ---
# Resume the existing session
@adk.prompt("Resume the session")
def resume_session(session: Session, state: State):
if "message_count" in state:
state["message_count"] += 1
else:
state["message_count"] = 1 # Should not happen if resuming
return f"Resumed session with ID: {session.session_id}. Message count: {state['message_count']}"
# To resume the session, you would invoke the ADK with the session ID
# For example, in a web service context, the session ID might be passed in the request
# The ADK will automatically load the state for the given session ID
# When the 'Resume the session' prompt is run for session 'my-persistent-session',
# the state will be loaded, and the output will be:
# "Resumed session with ID: my-persistent-session. Message count: 2" In this example, the Context Window CompressionContext window compression is a feature of the underlying Gemini API that the ADK leverages. It is not a feature that you enable or configure directly within the ADK code. The ADK is designed to work with the Gemini API and take advantage of its features, but the specifics of how the context window are managed and compressed are handled by the Gemini API itself. I hope this example and explanation are helpful. Footnotes: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a streaming tool that needs to continuously monitor something for long periods of time, and I was wondering how long the session could remain open for without manual user input as well as whether the time it remains open for counts towards the free tier quota for Gemini Live.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions