Skip to content

Commit 5e8aa15

Browse files
hangfeicopybara-github
authored andcommitted
feat: add support for session resumption(only transparent mode) config to run_config
This commit adds support for the session resumption configuration in the run_config. The SessionResumptionConfig is added to RunConfig to allow the user to set up a configuration for session resumption(only transparent mode for now). There are two modes of session resumption: manual and transparent. In manual mode, you have to manually bookkeeping the session information and restarts the session which is tricky to do right now. In transparent mode, the server does the bookkeeping for you and no hassle on ADK side. For now, the transparent mode should be enough. Also, added the relevant unit tests to check that every possible configuration is set properly and the run_config is correctly populated. This is needed for supporting the new session resumption feature. PiperOrigin-RevId: 786549455
1 parent 1639298 commit 5e8aa15

File tree

4 files changed

+595
-0
lines changed

4 files changed

+595
-0
lines changed

src/google/adk/agents/run_config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ class RunConfig(BaseModel):
7979
proactivity: Optional[types.ProactivityConfig] = None
8080
"""Configures the proactivity of the model. This allows the model to respond proactively to the input and to ignore irrelevant input."""
8181

82+
session_resumption: Optional[types.SessionResumptionConfig] = None
83+
"""Configures session resumption mechanism. Only support transparent session resumption mode now."""
84+
8285
max_llm_calls: int = 500
8386
"""
8487
A limit on the total number of llm calls for a given run.

src/google/adk/flows/llm_flows/basic.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ async def run_async(
7474
llm_request.live_connect_config.proactivity = (
7575
invocation_context.run_config.proactivity
7676
)
77+
llm_request.live_connect_config.session_resumption = (
78+
invocation_context.run_config.session_resumption
79+
)
7780

7881
# TODO: handle tool append here, instead of in BaseTool.process_llm_request.
7982

0 commit comments

Comments
 (0)