Unable to deploy agent to vertex ai agent engine
Bug:
white deploying agent to vertex ai agent engine i get error: ailed to generate schema for async_add_session_to_memory: async_add_session_to_memory is not fully defined; you should define Session, then call async_add_session_to_memory.model_rebuild().
Steps to reproduce:
- create an agent as per documentation here - https://google.github.io/adk-docs/get-started/quickstart/#run-your-agent
- setup the agent for deployment as per documentation here: https://google.github.io/adk-docs/deploy/agent-engine/
- run the python file deploy.py, please find code below:
import vertexai from agent import root_agent # modify this if your agent is not in agent.py from google.adk.sessions.session import Session PROJECT_ID = "my_project_id" LOCATION = "us-central1" # For other options, see https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/overview#supported-regions STAGING_BUCKET = "gs://my_bucket"
vertexai.init( project=PROJECT_ID, location=LOCATION, staging_bucket=STAGING_BUCKET, )
from vertexai.preview import reasoning_engines
app = reasoning_engines.AdkApp( agent=root_agent, enable_tracing=True, )
from vertexai import agent_engines
remote_app = agent_engines.create(
agent_engine=app,
requirements=[
"google-cloud-aiplatform[adk,agent_engines]"
]
)
print(f"Deployment finished!") print(f"Resource Name: {remote_app.resource_name}")
- when i run python deploy.py i get the error mentioned above, here's the log of previous steps:
Identified the following requirements: {'cloudpickle': '3.1.1', 'pydantic': '2.11.7', 'google-cloud-aiplatform': '1.111.0'}
The following requirements are missing: {'cloudpickle', 'pydantic'}
The following requirements are appended: {'cloudpickle==3.1.1', 'pydantic==2.11.7'}
The final list of requirements: ['google-cloud-aiplatform[adk,agent_engines]', 'cloudpickle==3.1.1', 'pydantic==2.11.7']
Using bucket agent_deploy_bucket_rhs
Wrote to gs://agent_deploy_bucket_rhs/agent_engine/agent_engine.pkl
Writing to gs://agent_deploy_bucket_rhs/agent_engine/requirements.txt
Creating in-memory tarfile of extra_packages
Writing to gs://agent_deploy_bucket_rhs/agent_engine/dependencies.tar.gz
failed to generate schema for async_add_session_to_memory: async_add_session_to_memory is not fully defined; you should define Session, then call async_add_session_to_memory.model_rebuild().
Desktop*
- OS: macOS sequoia version 15.16.1
- Python version: 3.12.8
- ADK version: 1.13.0
@RahilHuSh Install google-cloud-aiplatform[agent_engines,adk]==1.95.1
Hi, the issue is with your requirements (as specified in the logs), it seems you have not specified them all. It should look something like this:
remote_app = agent_engines.create(
app,
requirements=[
"google-cloud-aiplatform[adk,agent-engines]",
"google-adk",
"python-dotenv",
"cloudpickle",
"pydantic",
"google-auth",
"tqdm",
"requests",
],
extra_packages=[
"./<youragent>",
]
)
@RahilHuSh Test by setting your local environment to the same version below. (poetry.lock): google-adk==1.13.0 google-cloud-aiplatform[adk,agent_engines]==1.95.1 Then configure the requirements parameter of the agent_engines.create function in the same way. It worked for me. Give it a try. Unfortunately, this version 'google-cloud-aiplatform': '1.111.0' didn't work for me either.
remote_app = agent_engines.create(
app,
requirements=[
"google-adk",
"google-cloud-aiplatform[adk,agent_engines]==1.95.1",
"python-dotenv",
"cloudpickle",
"pydantic",
],
extra_packages=[
"./<youragent>",
]
)
Hello all.
I have the same issue. I tried use the approch by @daciolima but it don't work for my.
Below i'm sending my deploy.py script and my requeriments.txt file.
deploy.py
if remote_app is None:
print("Agent does not exist. Creating a new one...")
remote_app = agent_engines.create(
display_name="log-analyse-ai-agent-cloudtrail",
description="A log analysis AI agent for AWS CloudTrail",
agent_engine=app,
requirements="./requirements.txt",
)
else:
print("Agent exists. Updating the existing one...")
remote_app = agent_engines.update(
resource_name=RESOURCE_NAME,
agent_engine=app,
requirements="./requirements.txt"
)
requirements.txt
google-adk google-cloud-aiplatform[adk,agent_engines]==1.95.1 cloudpickle pydantic vertexai python-dotenv
@thomasErich135 Use the requirement parameter like this.
if remote_app is None:
print("Agent does not exist. Creating a new one...")
remote_app = agent_engines.create(
display_name="log-analyse-ai-agent-cloudtrail",
description="A log analysis AI agent for AWS CloudTrail",
agent_engine=app,
requirements=requirements=[
"google-adk",
"google-cloud-aiplatform[adk,agent_engines]==1.95.1",
"python-dotenv",
"cloudpickle",
"pydantic",
]
)
else:
print("Agent exists. Updating the existing one...")
remote_app = agent_engines.update(
resource_name=RESOURCE_NAME,
agent_engine=app,
requirements=requirements=requirements=[
"google-adk",
"google-cloud-aiplatform[adk,agent_engines]==1.95.1",
"python-dotenv",
"cloudpickle",
"pydantic",
]
)
@daciolima , consegue me ajudar com isso? Um mês atrás o deploy estava funcionando perfeitamente, agora estou passando por erros infinitos...
c:\agente_lorrany\mentor\agent\agent.py:21: UserWarning: Api key is used with an insecure connection.
qdrant_client_instance = qdrant_client.QdrantClient(
Using bucket viamentor
Writing to gs://viamentor/reasoning_engine/reasoning_engine.pkl
Writing to gs://viamentor/reasoning_engine/requirements.txt
Creating in-memory tarfile of extra_packages
Writing to gs://viamentor/reasoning_engine/dependencies.tar.gz
Creating ReasoningEngine
Create ReasoningEngine backing LRO: projects/842363521523/locations/us-central1/reasoningEngines/9200893621136523264/operations/332092523503681536
ReasoningEngine created. Resource name: projects/842363521523/locations/us-central1/reasoningEngines/9200893621136523264
To use this ReasoningEngine in another session:
reasoning_engine = vertexai.preview.reasoning_engines.ReasoningEngine('projects/842363521523/locations/us-central1/reasoningEngines/9200893621136523264')
WARNING:root:Failed to register API methods: {Unsupported api mode: async, Supported modes are: `` and stream.}
Deployment finalizado com sucesso!
Resource Name: projects/842363521523/locations/us-central1/reasoningEngines/9200893621136523264
Hey, I'm also seeing this message about async_add_session_to_memory is not fully defined but I thought it was a warning rather than an error because I do get a ReasoningEngine ID created and I'm able to use it with:
async def async_test(remote_app):
session = await remote_app.async_create_session(user_id="D")
print(f"session: {session}")
async for event in remote_app.async_stream_query(
...
Is there some functionality missing from the ReasoningEngine that I'm missing associated with that warning/error? Do you have any recommendations for how to test that functionality?
I'm also getting this issue even all documentation I followed. below is my deploy.py
I test the agent locally on web it working perfectly but only giving the issues in deployment
`import vertexai from vertexai import agent_engines from agent import root_agent
TODO: Fill in these values for your project
PROJECT_ID = "ai-experimentation-449407" LOCATION = "us-central1" STAGING_BUCKET = "gs://multi_tool_agent_code_base"
Initialize the Vertex AI SDK
vertexai.init( project=PROJECT_ID, location=LOCATION, staging_bucket=STAGING_BUCKET, )
app = agent_engines.AdkApp( agent=root_agent, enable_tracing=True, )
remote_app = agent_engines.create( app, requirements=[ "google-cloud-aiplatform[adk,agent-engines]", "google-adk", "python-dotenv", "cloudpickle", "pydantic", "google-auth", "tqdm", "requests", ] )
print(f"Deployment finished!") print(f"Resource Name: {remote_app.resource_name}")`
here is error logs I'm getting currently with this script
Identified the following requirements: {'cloudpickle': '3.1.1', 'pydantic': '2.11.9', 'google-cloud-aiplatform': '1.114.0'}
The final list of requirements: ['google-cloud-aiplatform[adk,agent-engines]', 'google-adk', 'python-dotenv', 'cloudpickle', 'pydantic', 'google-auth', 'tqdm', 'requests']
Using bucket multi_tool_agent_code_base
Wrote to gs://multi_tool_agent_code_base/agent_engine/agent_engine.pkl
Writing to gs://multi_tool_agent_code_base/agent_engine/requirements.txt
Creating in-memory tarfile of extra_packages
Writing to gs://multi_tool_agent_code_base/agent_engine/dependencies.tar.gz
failed to generate schema for async_add_session_to_memory: async_add_session_to_memory is not fully defined; you should define Session, then call async_add_session_to_memory.model_rebuild().
For further information visit https://errors.pydantic.dev/2.11/u/class-not-fully-defined
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1758109163.320030 33892 alts_credentials.cc:93] ALTS creds ignored. Not running on GCP and untrusted ALTS is not enabled.
Creating AgentEngine
Create AgentEngine backing LRO: projects/561149756761/locations/us-central1/reasoningEngines/1412762490529382400/operations/7090325406024204288
View progress and logs at https://console.cloud.google.com/logs/query?project=ai-experimentation-449407
Traceback (most recent call last):
File "d:\Latest-Research\multi_tool_agent\deploy.py", line 22, in
I have the same error. Were you able to resolve it?
@marcelonosoaresprogram I believe this text already guides you... Something is no longer supported. If possible, post part of the code in question. WARNING:root:Failed to register API methods: {Unsupported api mode: async, Supported modes are: `` and stream.}
I'm hoping https://github.com/googleapis/python-aiplatform/pull/5812 will fix this issue
I'm hoping googleapis/python-aiplatform#5812 will fix this issue
@yeesian, It appears that it does fix the issue!
I added your feature branch to requirements.txt and updated my venv:
git+https://github.com/googleapis/python-aiplatform.git@copybara_808159362#egg=google-cloud-aiplatform[adk,agent_engines]
With that change in place, output from agent_engines.create no longer has the "failed to generate schema for async_add_session_to_memory..." message:
Deploying google.adk.agents.Agent as an application.
Identified the following requirements: {'cloudpickle': '3.1.1', 'pydantic': '2.11.7', 'google-cloud-aiplatform': '1.114.0'}
The final list of requirements: ['cloudpickle==3.1.1', 'google-cloud-aiplatform[adk,agent_engines]', 'google-adk', 'google-genai', 'pydantic', 'python-dotenv']
Using bucket [redacted]
Wrote to gs://[redacted]/agent_engine/agent_engine.pkl
Writing to gs://[redacted]/agent_engine/requirements.txt
Creating in-memory tarfile of extra_packages
Writing to gs://[redacted]/agent_engine/dependencies.tar.gz
Creating AgentEngine
Create AgentEngine backing LRO: projects/[redacted]/locations/us-central1/reasoningEngines/[redacted]/operations/[redacted]
View progress and logs at https://console.cloud.google.com/logs/query?project=[redacted]
I'm hoping googleapis/python-aiplatform#5812 will fix this issue
Sorry, I didn’t fully understand — will this be fixed by updating the library? What steps do I need to take on my side to resolve the issue?
I'm hoping googleapis/python-aiplatform#5812 will fix this issue
Sorry, I didn’t fully understand — will this be fixed by updating the library? What steps do I need to take on my side to resolve the issue?
@HamzaAI9D You appear to have a more serious issue, which is indicated by google.api_core.exceptions.InvalidArgument. The traceback you provided doesn't have the details needed to tell which argument is invalid. You should be able to get the details you need from the log files, which your Traceback noted in this line:
View progress and logs at https://console.cloud.google.com/logs/query?project=ai-experimentation-449407
I'm hoping googleapis/python-aiplatform#5812 will fix this issue
@yeesian, It appears that it does fix the issue!
I added your feature branch to requirements.txt and updated my
venv:git+https://github.com/googleapis/python-aiplatform.git@copybara_808159362#egg=google-cloud-aiplatform[adk,agent_engines]With that change in place, output from
agent_engines.createno longer has the "failed to generate schema for async_add_session_to_memory..." message:Deploying google.adk.agents.Agent as an application. Identified the following requirements: {'cloudpickle': '3.1.1', 'pydantic': '2.11.7', 'google-cloud-aiplatform': '1.114.0'} The final list of requirements: ['cloudpickle==3.1.1', 'google-cloud-aiplatform[adk,agent_engines]', 'google-adk', 'google-genai', 'pydantic', 'python-dotenv'] Using bucket [redacted] Wrote to gs://[redacted]/agent_engine/agent_engine.pkl Writing to gs://[redacted]/agent_engine/requirements.txt Creating in-memory tarfile of extra_packages Writing to gs://[redacted]/agent_engine/dependencies.tar.gz Creating AgentEngine Create AgentEngine backing LRO: projects/[redacted]/locations/us-central1/reasoningEngines/[redacted]/operations/[redacted] View progress and logs at https://console.cloud.google.com/logs/query?project=[redacted]
fixed by above. closing.