Repository navigation
feat(cli): seed adk web sessions from initial_state.json - #7465
Open
BichengWang wants to merge 2 commits into
Open
BichengWang wants to merge 2 commits into
BichengWang wants to merge 2 commits into
Conversation
When an agent directory contains initial_state.json, the dev server merges it into the state of each session created through the session endpoints. State sent by the client takes precedence. The file is read per request, and a missing or malformed file leaves behavior unchanged. ApiServer is not affected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4961
Problem
adk run --replaycan preload session state from a JSON file, butadk webhas no equivalent. Anyone iterating on an agent that depends on session state has to re-enter the same values in the UI for every new session.Change
If
<agents_dir>/<app_name>/initial_state.jsonexists,adk webmerges it into the state of each session created through the session endpoints.{**file_state, **client_state}.DevServer._create_session.ApiServer(adk api_server) is untouched._get_agent_dirvalidation.Not covered: sessions the runner creates itself under
--auto_create_sessionare not seeded, since they never go through_create_session.app:anduser:keys in the file follow the normal state scoping, so they write to shared state.Testing plan
Unit tests in
tests/unittests/cli/test_fast_api.py:ApiServerignores the fileThe two seeding tests fail without the change.
pytest tests/unittests/cli/test_fast_api.pygives 231 passed, 5 skipped, 1 xfailed. pyink and isort are clean.