adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

Deployed Reasoning Engine Returns Zero Events with VertexAiRagRetrieval

Open anwoflow opened this issue 1 year ago • 4 comments

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.

anwoflow avatar May 01 '25 18:05 anwoflow

I see. We will route this to RAG POC to take a look.

hangfei avatar May 31 '25 17:05 hangfei

I'm also encountering this issue when trying to connect the agent to my RAG Engine resource in GCP. I've noticed that at least for my use case the limitations highlighted here were not a problem when running locally. I gave my agent access to an MCP tool and the VertexAiRagRetrieval built-in tool and it seemed to work fine locally, but failing with the INVALID_ARGUMENT error in the cloud. That's when I found out about the limitations piece of the docs, and redesigned my flow a little bit, but still no luck getting this to work in Agent Engine unfortunately

Jorgelmh avatar Jun 21 '25 18:06 Jorgelmh

Same issue here. It works properly locally, but when I deploy my agent to Agent Engine I get the 400 INVALID_ARGUMENT error. Do you have an ETA for this issue to be resolved?

DamiMartinez avatar Jun 27 '25 15:06 DamiMartinez

Hi @anwoflow and thanks to everyone who participated in this thread.

We're currently doing some housekeeping on our issue tracker. Given the rapid pace of development and the number of updates since this was last active, there's a good chance this issue has been resolved in a newer version. To help us keep our backlog focused on current issues, we are closing this as stale.

If you're still facing this problem, could you please update to the very latest version of the library and confirm the issue still exists? If it does, please comment here, and we will be happy to reopen this issue and investigate further.

Thanks for your contribution and understanding!

klateefa avatar Oct 07 '25 07:10 klateefa