You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm developing a multi-agent system where specialist agents need access to the current user's context (specifically their email) for authorization checks. The tools use ToolContext to access context.session.user_id.
When deployed to production (Vertex AI), the ToolContext works perfectly. However, during local development with adk web, the ToolContext appears to be empty or not properly initialized, making it impossible to test authorization flows locally.
Current Setup:
pythonfrom typing import TypedDict
from google.adk.tools import ToolContext
class ProjectOutput(TypedDict):
status: str
message: str
async def update_project(
project_key: str,
context: ToolContext
) -> ProjectOutput:
"""Update project settings (requires authorization)"""
# Need user email for permission check
user_email = context.session.user_id # This is None in adk web
# Check if user has permission
if not await check_user_permission(project_key, user_email):
return {"status": "error", "message": "Permission denied"}
# ... actual update logic
Problem:
When running adk web src/agents/, the ToolContext doesn't contain any session information, causing the authorization logic to fail.
Question:
Is there a way to inject or mock session data into ToolContext for local testing with adk web?
What's the recommended pattern for handling user context in tools that works both in production and local development?
Should we avoid ToolContext for user authentication and use a different approach?
Environment:
Google ADK version: latest
Python 3.13
Testing with: adk web
Any guidance on best practices for local development with user context would be appreciated!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm developing a multi-agent system where specialist agents need access to the current user's context (specifically their email) for authorization checks. The tools use ToolContext to access context.session.user_id.
When deployed to production (Vertex AI), the ToolContext works perfectly. However, during local development with adk web, the ToolContext appears to be empty or not properly initialized, making it impossible to test authorization flows locally.
Current Setup:
Problem:
When running adk web src/agents/, the ToolContext doesn't contain any session information, causing the authorization logic to fail.
Question:
Is there a way to inject or mock session data into ToolContext for local testing with adk web?
What's the recommended pattern for handling user context in tools that works both in production and local development?
Should we avoid ToolContext for user authentication and use a different approach?
Environment:
Google ADK version: latest
Python 3.13
Testing with: adk web
Any guidance on best practices for local development with user context would be appreciated!
Beta Was this translation helpful? Give feedback.
All reactions