Skip to content

agent_engines.get() on Terraform-deployed engines returns empty operation_schemas() — class_methods not documented for Terraform deployments #6470

@PhilippeMoussalli

Description

@PhilippeMoussalli

Environment details

  • OS type and version: macOS
  • Python version: 3.13
  • google-cloud-aiplatform version: 1.140.0

Steps to reproduce

  1. Deploy an ADK agent to Agent Engine using Terraform (google_vertex_ai_reasoning_engine) with package_spec (pickle + requirements URIs) instead of agent_engines.create()
  2. Fetch the deployed engine from Python:
  import vertexai                                                                                                              
  from vertexai import agent_engines
                                                                                                                               
  vertexai.init(project="my-project", location="us-central1")                                                                  
  adk_app = agent_engines.get("projects/.../reasoningEngines/...")
  print(adk_app.operation_schemas())  # returns None                                                                           
  adk_app.async_create_session(user_id="user-123")  # AttributeError            

Code example

  import vertexai                                                                                                              
  from vertexai import agent_engines

  vertexai.init(project="my-project", location="us-central1")                                                                  
  adk_app = agent_engines.get("projects/.../reasoningEngines/...")
                                                                                                                               
  # operation_schemas() returns None — class_methods not in resource spec
  print(adk_app.operation_schemas())
                                                                                                                               
  # AttributeError: 'AgentEngine' object has no attribute 'async_create_session'
  await adk_app.async_create_session(user_id="user-123")                                                                       
                                                                                                                               
  Stack trace
                                                                                                                               
  AttributeError: 'AgentEngine' object has no attribute 'async_create_session'

Root cause (investigated)

AgentEngine.init calls _register_api_methods_or_raise(self), which reads operation_schemas() → spec.get("class_methods",
[]). When deploying via agent_engines.create(), the SDK calls _generate_class_methods_spec_or_raise() and writes the result
into spec.class_methods. When deploying via Terraform, this step never happens — class_methods stays None — so no methods are
bound.

Workaround

Manually set class_methods in the Terraform spec block:

  class_methods = jsonencode([
    { api_mode = "",             name = "async_create_session", parameters = { type = "object", required = [], properties = {}
  } },                                                                                                                         
    { api_mode = "async_stream", name = "async_stream_query",   parameters = { type = "object", required = [], properties = {} 
  } },                                                                                                                         
    # ... full AdkApp.register_operations() list                                                                               
  ])                                            

Suggested fix

Either document the class_methods requirement for Terraform deployments in the
https://google.github.io/adk-docs/deploy/agent-engine/, or have agent_engines.get() fall back to the known ADK schemas when
agent_framework == "google-adk" and class_methods is empty

Metadata

Metadata

Assignees

Labels

api: vertex-aiIssues related to the googleapis/python-aiplatform API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions