Skip to content

Conversation

@kevinkassimo
Copy link
Contributor

Will close google/adk-python#3223 with this merged.

Docs incorrectly wrap state in an additional state key. This results in "state": {"state": {...}} in the actual session state. This is because in the original source code, FastAPI would place every remaining payload under the state param
https://github.com/google/adk-python/blob/36ca4f1204fff4302f143dddccbf6259d3ae7872/src/google/adk/cli/adk_web_server.py#L761-L776

Update docs to reflect this.

Testing: Verified no state key is needed by creating a minimal agent and run session creation:

# Setup a simple my_sample_agent

$ adk api_server 2>&1 > /dev/null &

$ curl -X POST http://localhost:8000/apps/my_sample_agent/users/u_123/sessions/s_abc   -H "Content-Type: application/json"   -d '{"visit_count": 5}'
{"id":"s_abc","appName":"my_sample_agent","userId":"u_123","state":{"visit_count":5},"events":[],"lastUpdateTime":1761590753.623595}

Copy link
Collaborator

@koverholt koverholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and for your contribution. ❤️

That's a great catch, thanks for linking to the issue and including info on the verification test. I also tested and can confirm the revised requests are working as expected without wrapping the vars with another state key. I also checked and it looks like you covered all of the occurrences of where the changes need to happen.

LGTM, and cc @joefernandez for additional / second review.

@joefernandez joefernandez merged commit 8d46b7e into google:main Oct 31, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

before_agent_callback Fails to Read existing Session Context Variables

3 participants