8000 Agent Engine: streaming_agent_run_with_events Fails with 400 Reasoning Engine Execution failed (Service-side TypeError: unexpected keyword argument) for ADK 1.0.0 Agent · Issue #1075 · google/adk-python · GitHub
[go: up one dir, main page]

Skip to content
Agent Engine: streaming_agent_run_with_events Fails with 400 Reasoning Engine Execution failed (Service-side TypeError: unexpected keyword argument) for ADK 1.0.0 Agent #1075
Open
@Hrishnugg

Description

@Hrishnugg

After successfully deploying an ADK 1.0.0 agent to Vertex AI Agent Engine and resolving initial session creation issues (related to ADK 1.0.0 async session methods, fixed by google-cloud-aiplatform>=1.95.0), calls to AgentEngine.streaming_agent_run_with_events() from the Python client SDK consistently fail. The client receives a FailedPrecondition - 400 Reasoning Engine Execution failed with empty "Error Details".
However, Google Cloud Logs (reasoning_engine_stderr) for the deployed Agent Engine instance reveal a TypeError: AdkApp.streaming_agent_run_with_events() got an unexpected keyword argument 'X' (where 'X' has been tested as message, input, input_text, and new_message). This occurs even when the message/input/etc. value is a dictionary structured like a google.genai.types.Content object (e.g., {"parts": [{"text": "..."}], "role": "user"}).

This suggests a mismatch or undocumented parameter mapping between the client SDK's AgentEngine.streaming_agent_run_with_events(**kwargs) method and the actual method signature expected by the deployed ADK 1.0.0 agent on the Agent Engine service for its streaming input.

Environment:

  • ADK Version: google-adk==1.1.1
  • Client SDK Version: google-cloud-aiplatform==1.95.1
  • Agent Deployed: An agent built with google.adk.agents.Agent (ADK 1.0.0), including usage of BuiltInCodeExecutor. The agent itself deploys successfully.
  • Deployment Method: Python script using vertexai.init() and vertexai.agent_engines.create().
  • Client Interaction: Python client (FastAPI wrapper) using vertexai.init() and vertexai.agent_engines.get(AGENT_ID) to obtain an AgentEngine client object.

Steps to Reproduce:

  1. Define an ADK Agent using google-adk>=1.0.0. (User's agent is a multi-agent system with PresenterAgent -> InternalCoordinatorAgent -> RAG, Search, Coding specialists).
  2. Deploy the Agent to Vertex AI Agent Engine using vertexai.agent_engines.create() with requirements including google-adk>=1.0.0, google-cloud-aiplatform[adk,agent_engines,rag]>=1.95.0, and other necessary dependencies (e.g., llama-index). Deployment completes successfully.
  3. Attempt to Interact with the Deployed Agent using the Python SDK:
    import vertexai
    from vertexai import agent_engines
    # from google.genai import types as genai_types # If constructing Content object
    
    PROJECT_ID = "your-project-id" 
    LOCATION = "your-location" 
    AGENT_ID = "your-deployed-agent-engine-id" 
    USER_ID = "test-user-for-session"
    MESSAGE_TEXT = "Hello Agent" # Or a more complex query
    
    vertexai.init(project=PROJECT_ID, location=LOCATION)
    agent_client = agent_engines.get(AGENT_ID) # Returns <class 'vertexai.agent_engines._agent_engines.AgentEngine'>
    
    print(f"Agent client type: {type(agent_client)}")
    print(f"Agent client attributes: {dir(agent_client)}")
    
    # --- This part now succeeds ---
    print(f"Attempting to create session with user_id: {USER_ID}")
    session_info = agent_client.create_session(user_id=USER_ID)
    session_id = None
    if isinstance(session_info, dict) and 'id' in session_info:
        session_id = session_info['id']
    else:
        # Add other extraction logic if needed or raise error
        raise ValueError(f"Could not determine session_id. Got: {session_info}")
    print(f"Session created with ID: {session_id}")
    # --- End session creation ---
    
    # Prepare message payload (tried as string, Content object, and dict resembling Content)
    # Attempt 1 (Fail
    6C8B
    ed with client-side ValueError: Unable to coerce Content object):
    # content_obj = genai_types.Content(parts=[genai_types.Part(text=MESSAGE_TEXT)], role="user")
    # query_kwargs = {"session_id": session_id, "message": content_obj}
    
    # Attempt 2 (Failed with service-side TypeError: ...unexpected keyword 'message'):
    # query_kwargs = {"session_id": session_id, "message": MESSAGE_TEXT} 
    
    # Attempt 3 (Failed with service-side TypeError: ...unexpected keyword 'input'):
    # message_payload_dict = {"parts": [{"text": MESSAGE_TEXT}], "role": "user"}
    # query_kwargs = {"session_id": session_id, "input": message_payload_dict}
    
    # Attempt 4 (Current - Failed with service-side TypeError: ...unexpected keyword 'new_message'):
    message_payload_dict = {"parts": [{"text": MESSAGE_TEXT}], "role": "user"}
    query_kwargs = {"session_id": session_id, "new_message": message_payload_dict} # Last attempt
    
    print(f"Calling streaming_agent_run_with_events with kwargs: {query_kwargs}")
    try:
        for event in agent_client.streaming_agent_run_with_events(**query_kwargs):
            print(f"Received event: {event}") 
            # Event processing logic...
    except Exception as e:
        print(f"Error during streaming_agent_run_with_events: {type(e).__name__} - {e}")
        # This typically prints: 
        # FailedPrecondition - 400 Reasoning Engine Execution failed. Error Details: 
        # (And the corresponding Cloud Log shows the TypeError from AdkApp)

Expected Behavior:
The agent_client.streaming_agent_run_with_events() call, with the correctly named and structured keyword argument for the message content, should successfully initiate a stream from the deployed ADK 1.0.0 agent.

Actual Behavior (from Cloud Logs when message=, input=, or new_message= used):
The Agent Engine service logs (reasoning_engine_stderr) show:
TypeError: AdkApp.streaming_agent_run_with_events() got an unexpected keyword argument 'X'
(where X is message, input, or new_message respectively).

This occurs after session creation is successful. The client SDK's inspect.signature for AgentEngine.streaming_agent_run_with_events shows it takes (**kwargs).

Suspicion:
There is an undocumented or mismatched keyword argument name expected by the deployed ADK 1.0.0 agent's streaming method when invoked via the AgentEngine client's streaming_agent_run_with_events. The ADK's internal _StreamRunRequest looks for kwargs.get("message") expecting a Content object, but the service-side invocation of the AdkApp method rejects message= (and other common alternatives) as a keyword.

Request:
Please provide the correct keyword argument name and expected value structure for the primary query/message content when using vertexai.agent_engines.AgentEngine.streaming_agent_run_with_events() to interact with a deployed ADK 1.0.0 agent.

Additional Logs

Traceback (most recent call last):
File "/code/app/api/factory/python_file_api_builder.py", line 260, in _invoke_callable_or_raise
return invocation_callable(**invocation_payload)

and

Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
result = await app( # type: ignore[func-returns-value]

and

[4] ERROR: TypeError when invoking Agent Engine: AdkApp.streaming_agent_run_with_events() got an unexpected keyword argument 'message'. Request is: {'message': {'parts': [{'text': 'Hello Agent'}], 'role': 'user'}, 'session_id': '3748380824379064320'}

Metadata

Metadata

Assignees

Labels

coreIssues related to the core interface and implementation

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0