Agent Engine session state update: how to modify state after session creation? #4153
-
|
I am using Vertex AI Agent Engine and creating a session via the synchronous I create the session using: Endpoint Payload {
"class_method": "create_session",
"input": {
"user_id": "<USER_ID>",
"state": {
"auth_token": "INITIAL_TOKEN"
}
}
}This successfully creates the session, and the agent can access Problem The When I try to send an updated Endpoint and include {
"code": 498,
"message": "Runner.run_async() got an unexpected keyword argument 'state'"
}This suggests that Questions
Context
Any guidance or recommended best practices would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: Session Hello @rohan-kavari, Thank you for the detailed question. I can clarify how session state is managed in the ADK and why you are encountering this behavior. The error To answer your questions directly:
Recommended Best Practice for Expiring TokensFor your use case of handling an expiring Instead of storing the token in the session Here’s an example payload for {
"input": {
"user_query": "The user's actual message to the agent",
"auth_token": "LATEST_UPDATED_TOKEN"
}
}This approach ensures that your agent's tools always have access to a valid token for downstream API calls without needing to modify the session state. I hope this clarifies things! [1] sessions/state.html |
Beta Was this translation helpful? Give feedback.
-
|
I found out that the payload should be as follows |
Beta Was this translation helpful? Give feedback.
I found out that the payload should be as follows
{ "user_id": user_id, "session_id": session_id, "message": message, "state_delta": { "auth_token": "UPDATED_TOKEN" } }We need to use
state_deltainstead ofstatewhile updating the state