adk-web icon indicating copy to clipboard operation
adk-web copied to clipboard

Setting Session variables when testing it out through ADK Web

Open kanlanc opened this issue 7 months ago • 7 comments

I built a custom root agent that would require setting some custom session variables when I run the entire application.

How do I set session variables when im using adk web ?

Im positive, i reviewed the entire docs but I couldnt find anything for this specifically

kanlanc avatar May 12 '25 00:05 kanlanc

Currently all my agents are running with api_server command and I've built a custom streamlit UI (common to all agents), Where I can set the state before Creating the session and asking Questions.

would Love to have this feature with "ADK Web" Command. If there's a "Fallback" state when no state is initialized, especially when using "adk web", that would be awesome.

veevortexiq avatar May 13 '25 13:05 veevortexiq

The ADK documentation doesn't mention anything about state initialization when using adk web. This is inconvenient, but it is possible to initialize it using the following method. You can try setting up an initial session using --session_db_url.

1. Create a session db with sqlite
   adk web --session_db_url 'sqlite:///session.db'
2. Modify session.db. Session information is stored in the sessions table. Add the state value here.
   [Table] sessions / [Field] state = {"your state": "state value"}
3. Always run it with the --session_db_url option like this
   adk web --session_db_url 'sqlite:///session.db'
4. Go to http://localhost:8000/ and select the session id that saved the state in [Sessions]. 
5. In the [State] menu, you can see the state you saved.

rednakta avatar May 22 '25 01:05 rednakta

Currently state is read only from adk web's perspective. We are aware of this and it's on the roadmap, stay tuned.

wyf7107 avatar May 22 '25 23:05 wyf7107

For cases where I create a Runner (to keep the session persistent, for example), is it not possible to debug with the ADK Web?

lvcarnevalli avatar Jul 14 '25 22:07 lvcarnevalli

The ADK documentation doesn't mention anything about state initialization when using adk web. This is inconvenient, but it is possible to initialize it using the following method. You can try setting up an initial session using --session_db_url.

1. Create a session db with sqlite
   adk web --session_db_url 'sqlite:///session.db'
2. Modify session.db. Session information is stored in the sessions table. Add the state value here.
   [Table] sessions / [Field] state = {"your state": "state value"}
3. Always run it with the --session_db_url option like this
   adk web --session_db_url 'sqlite:///session.db'
4. Go to http://localhost:8000/ and select the session id that saved the state in [Sessions]. 
5. In the [State] menu, you can see the state you saved.

This actually works, just tested, session_db_url is going to be deprecated, you can run adk web --session_service_uri 'sqlite:///session.db'. Its going to create a session.db in your local directory if it's not already there

whanyu1212 avatar Sep 04 '25 08:09 whanyu1212

SOLUTION

  1. Run (Creates a session.db in your local directory if it's not already there) adk web --session_service_uri 'sqlite:///session.db'
  2. Modify session.db.(Session information is stored in the sessions table. Add the state value here.) [Table] sessions / [Field] state = {"your state": "state value"}
  3. Always run it with the --session_service_uri option like this adk web --session_service_uri 'sqlite:///session.db'
  4. Go to http://localhost:8000/ and select the session id that saved the state in [Sessions].
  5. In the [State] menu, you can see the state you saved.

IAmNo1Special avatar Sep 04 '25 16:09 IAmNo1Special

I am developing a new Datastore session component. How can I try out in ADK web?

pentium10 avatar Sep 21 '25 13:09 pentium10