I created an AI agent using ADK, and then deployed it to Agent Engine with using following code:
import os
import vertexai
from vertexai import agent_engines
from dotenv import load_dotenv
from agent import root_agent
load_dotenv()
vertexai.init(
project=os.getenv("GOOGLE_CLOUD_PROJECT"),
location=os.getenv("GOOGLE_CLOUD_LOCATION"),
staging_bucket="gs://" + os.getenv("GOOGLE_CLOUD_PROJECT")+"-bucket",
)
remote_app = agent_engines.create(
display_name="make-goal-agent",
agent_engine=root_agent,
requirements=[
"google-cloud-aiplatform[adk,agent_engines]"
],
gcs_dir_name = "make-goal-agent"
)
and then I used the following code to query it:
from vertexai import agent_engines
# 1. Get your app
adk_app = agent_engines.get("1492406714798964736")
# 2. List (or create) a session for your user
se_list = adk_app.list_sessions(user_id="Nvc0fHCmtpgl4DfdTKfC7BewPGk1")
if not se_list.get("sessions"):
# no sessions yet, so create one
session = adk_app.create_session(user_id="Nvc0fHCmtpgl4DfdTKfC7BewPGk1")
session_id = session["id"]
else:
session_id = se_list["sessions"][0]["id"]
print(session_id)
# 3. Stream your query into *that* session
for event in adk_app.stream_query(
user_id="Nvc0fHCmtpgl4DfdTKfC7BewPGk1",
session_id=session_id, # use the real variable here
message="""
{"text": "yh I would like to learn the bascis and then continue to the advance"}
"""
):
print(event)
few days before this worked fine, but now everytime I change the message, and run it, it always starts from the beginning. like it does not have any idea about what we told before.