Replies: 3 comments
-
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: For local testing with Hello! That's a great question, and it touches on a common challenge when developing locally versus in a deployed environment. Here’s a breakdown of the recommended patterns for handling user context with ADK: 1. Handling
|
Beta Was this translation helpful? Give feedback.
-
@this-dave thank you for your questions :) You don't have a way to change user_id on ADK Web, as it's hard coded, because adk web is mainly targeted for development / testing tool https://github.com/google/adk-web/blob/3ddf6fabf4da669092e1329d92f6f4a855804d5a/src/app/components/chat/chat.component.ts#L174 but you are able to change user context , i.e. session state by calling the API server to inject some session state yourself:
as suggested by bot answer above, you should have some fallback logic to check permission via session state. BTW on local how do you check permission ? you still connect to a remote DB / server to check permission ? |
Beta Was this translation helpful? Give feedback.
-
Hi, as Sean point out, user_id is not something users can override at the moment. However, if you wish to change the state, you can also click the three dots next to the attachment buton in the chat input field. There you can specify what state you want to alter and sending the message along with this will update the state |
Beta Was this translation helpful? Give feedback.
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