-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Summary
ADK v1.23.0 added support for automatic session creation via the auto_create_session parameter in the Runner class (commit 8e69a58). However, this feature is not exposed in the adk api_server CLI, requiring frontend applications to manually create sessions before calling /run.
Current Behavior
The _create_runner method in adk_web_server.py creates the Runner without the auto_create_session parameter:
def _create_runner(self, agentic_app: App) -> Runner:
return Runner(
app=agentic_app,
artifact_service=self.artifact_service,
session_service=self.session_service,
memory_service=self.memory_service,
credential_service=self.credential_service,
# auto_create_session is not passed, defaults to False
)This means /run returns 404 Session not found if the session doesn't exist, even though the Runner has the capability to auto-create it.
Proposed Solution
Add a --auto_create_session flag to adk api_server:
adk api_server --auto_create_session --allow_origins="https://example.com" .This would pass auto_create_session=True to the Runner, enabling the feature that already exists in the codebase.
Use Case
Frontend applications (especially those running in restricted environments like Looker Extensions) would benefit from simplified session management. Currently, we need to:
- GET
/sessions/{id}to check if session exists - POST
/sessions/{id}to create if not found - POST
/runto send the message
With --auto_create_session, step 1 and 2 become unnecessary, reducing latency and code complexity.
Alternatives Considered
- Manual session creation in frontend - Current workaround, adds complexity
- Custom FastAPI server - Requires maintaining a fork
- Environment variable - Could also work (e.g.,
ADK_AUTO_CREATE_SESSION=1)
Additional Context
- ADK Version: 1.23.0
- The
auto_create_sessionfeature works correctly when using the Runner directly in Python scripts - This is specifically about exposing the existing feature via the CLI