I'm facing an issue calling my deployed ADK agent via Vertex AI Agent Engine REST API

When i try to invoke my deployed agent using the query url i get the following error:

Status Code: 400
:cross_mark: ERROR RESPONSE:
{
“error”: {
“code”: 400,
“message”: “Reasoning Engine Execution failed.\nPlease refer to our documentation (https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/troubleshooting/use) for checking logs and other troubleshooting tips.\nError Details: {\“detail\”:\“Agent Engine Error: Invalid request. Exception: AgentEngineApp.query() missing 1 required positional argument: ‘input’\\n\\nRequest Data: {‘company’: ‘deloitte’, ‘persona’: ‘Engineering’}\”}”,
“status”: “FAILED_PRECONDITION”
}
} Has anyone got any solution to the error?

Hi @Sasika_Nagaraj,

Thank you for posting in this community!

This error seems related to your query request? Are you using the SDK or REST API? Can you share your request?

Best

I am using the query url for testing the agent using python code snippet that i am running in google colab.

The snippet is like :

import json
import pathlib
import requests

from google.oauth2 import service_account
import google.auth.transport.requests

PROJECT_ID = “<YOUR_PROJECT_ID>” # e.g. “my-gcp-project”
LOCATION = “<YOUR_LOCATION>” # e.g. “us-central1”
REASONING_ENGINE_ID = “<YOUR_ENGINE_ID>” # e.g. “1234567890123456789”

AGENT_QUERY_URL = (
f"https://{LOCATION}-aiplatform.googleapis.com/v1/"
f"projects/{PROJECT_ID}/locations/{LOCATION}/"
f"reasoningEngines/{REASONING_ENGINE_ID}:query"
)

SERVICE_ACCOUNT_KEY_PATH = “<PATH_TO_SERVICE_ACCOUNT_KEY>.json”
SCOPES = [“https://www.googleapis.com/auth/cloud-platform”\\]

def query_vertex_ai_agent():

key_path = pathlib.Path(SERVICE_ACCOUNT_KEY_PATH)
if not key_path.is_file():
print(f":cross_mark: Service account key not found: {SERVICE_ACCOUNT_KEY_PATH}")
return

credentials = service_account.Credentials.from_service_account_file(
    SERVICE_ACCOUNT_KEY_PATH,
    scopes=SCOPES,
)

auth_req = google.auth.transport.requests.Request()
credentials.refresh(auth_req)
access_token = credentials.token

print("✅ Access token generated successfully")

# 2. Headers
headers = {
    "Authorization": f"Bearer {access_token}",
    "Content-Type": "application/json",
}

# Request body (example data)
request_body = {
    "class_method": "query",
    "company": "<COMPANY_NAME>",    # e.g. "deloitte"
    "persona": "<PERSONA_NAME>"     # e.g. "Engineering"
}

print("\n--- REQUEST BODY ---")
print(json.dumps(request_body, indent=2))
print("--------------------\n")

# 3. Call API
response = requests.post(
    AGENT_QUERY_URL,
    headers=headers,
    json=request_body,
)

print(f"Status Code: {response.status_code}")

if response.status_code != 200:
    print("❌ ERROR RESPONSE:")
    print(response.text)
    return

# 4. Success
result = response.json()
print("\n✅ FULL RESPONSE:")
print(json.dumps(result, indent=2))

if name == “main”:
query_vertex_ai_agent()

the error i get is as above

1 Like

Thank you for sharing @Sasika_Nagaraj!

Having a quick look at your request, the following request body should be used:

request_body = {
        "class_method": "query", 
        "input": {
                   "company": "",    # e.g. "deloitte"
                   "persona": ""     # e.g. "Engineering"
        }
    }

I am assuming that you deployed your agent with query method which would accept company and persona params.

if i try this also i get the error:

-– FIXED REQUEST BODY —
{
“class_method”: “query”,
“input”: {
“company”: “deloitte”,
“persona”: “engineering”
}
}

Status Code: 400
:cross_mark: ERROR RESPONSE:
{
“error”: {
“code”: 400,
“message”: “Reasoning Engine Execution failed.\nPlease refer to our documentation (https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/troubleshooting/use) for checking logs and other troubleshooting tips.\nError Details: {\“detail\”:\“Agent Engine Error: Invalid request. Exception: AgentEngineApp.query() missing 1 required positional argument: ‘input’\\n\\nRequest Data: {‘company’: ‘deloitte’, ‘persona’: ‘engineering’}\”}”,
“status”: “FAILED_PRECONDITION”
}
}

Hi @Sasika_Nagaraj

The very first error message is very specific: AgentEngineApp.query() missing 1 required positional argument: ‘input’. This tells us exactly how your agent’s code is defined on the server. The Reasoning Engine tries to map the JSON keys to the function arguments. It sees company and persona, but it is looking for a key named input. Since it can’t find input, it crashes.
Try the following:

CORRECTED REQUEST BODY

We wrap the data inside the ‘input’ key to match the function signature

request_body = {
“input”: {
“company”: “deloitte”,
“persona”: “Engineering”
}
}

If the above doesn’t work, check my next suggestions :thinking:
The error suggests checking logs. Have you tried it? If so, what are the results? If not, type

gcloud logging read “resource.type=aiplatform.googleapis.com/ReasoningEngine” --limit 50

Also, I can read that it looks for a positional argument. Do it differently. Try it as a list:
request_body = {
“class_method”: “query”,
“input”: [“deloitte”, “Engineering”] # Try as a list if it expects positional args
}

Another solution I can think of for you to try is to modify your agent class to accept kwargs:
class AgentEngineApp:
def query(self, **kwargs):
company = kwargs.get(“company”)
persona = kwargs.get(“persona”)

… rest of logic

I tried all these methods but it is not working..

To address persistent execution failures, I introduced a custom application wrapper, CustomApp.py, which inherited from google.adk.apps.App. This file was used to provide a necessary synchronous execution path and to force a specific method call onto the nested SequentialAgent. While using this wrapper, the SequentialAgent object repeatedly failed to execute, returning an AttributeError or TypeError when we attempted to call it with every standard method available, including all synchronous options (.invoke(), .run(), .predict(), .process(), .execute()) and the asynchronous methods (.ainvoke(), .arun()), as well as the direct callable syntax ().