Skip to content

Deployed Reasoning Engine Returns Zero Events with VertexAiRagRetrieval #496

@anwoflow

Description

@anwoflow

A deployed Vertex AI Reasoning Engine using an agent definition that includes the VertexAiRagRetrieval tool consistently returns zero events ([]) from stream_query(). The same agent definition functions correctly and uses the RAG tool when tested locally via adk web in a Python 3.11 environment. Replacing VertexAiRagRetrieval with a different tool (e.g., GoogleSearch) allows the deployed agent to function correctly.

Steps to reproduce the behavior:

  1. Environment: Use Python 3.11 and install dependencies including google-cloud-aiplatform[adk,agent_engines]==1.91.0 and llama-index>=0.12.0,<0.13.0.
  2. RAG Corpus: Create a Vertex AI RAG Corpus and upload at least one text file.
  3. Agent Definition (bot_agent/agent.py): Create a simple agent definition like the following, inserting your RAG_CORPUS resource name:
    import os
    from google.adk.agents import Agent
    from google.adk.tools.retrieval.vertex_ai_rag_retrieval import VertexAiRagRetrieval
    from vertexai.preview import rag
    from dotenv import load_dotenv

    load_dotenv() # To get RAG_CORPUS

    rag_tool = VertexAiRagRetrieval(
        name='retrieve_support_documentation',
        description=('Use this tool to retrieve relevant information from the knowledge base.'),
        rag_resources=[rag.RagResource(rag_corpus=os.environ.get("RAG_CORPUS"))],
        similarity_top_k=5,
        vector_distance_threshold=0.6,
    )

    root_agent = Agent(
        model="gemini-2.5-flash-preview-04-17", # Or gemini-2.0-flash-001, tested with both
        name='test_rag_agent',
        instruction="""Answer questions using the knowledge base via the retrieve_support_documentation tool.""",
        tools=[rag_tool]
    )
  1. Deploy Agent, following those guidelines https://google.github.io/adk-docs/deploy/agent-engine/#send-queries-to-your-agent-local

  2. Test the agent.

I want to emphasize that:

agent + search, agent deployed locally - works
agent + search, agent deployed remotely - works
agent + rag, agent deployed locally - works
agent + rag, agent deployed remotely - does not work.

In the beginning I thought the issue was related to #454 , since I was getting locally some similar errors, like
google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Request contains an invalid argument.', 'status': 'INVALID_ARGUMENT'}}

but after updating the adk version , and python 3.11 , it was resolved locally. but I'm still having this inconsistency on remotely deployed agent, and only with VertexAiRagRetrieval.

Metadata

Metadata

Assignees

Labels

mcp[Component] Issues about MCP supporttools[Component] This issue is related to tools

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions