#!/usr/bin/env python3 """ agent.py — OSVauco root agent using ADK 2.0. Requires: google-adk >= 1.29, google-cloud-aiplatform >= 1.111.0 """ import os from google.adk.agents import Agent from google.adk.integrations.secret_manager.secret_client import SecretManagerClient from vertexai.preview import rag PROJECT_ID = "propane-will-491900-m5" LOCATION = "us-central1" # --- Secret Manager integration (ADK >= 1.29) --- _sm = SecretManagerClient() def _get_secret(name: str) -> str: return _sm.get_secret( f"projects/{PROJECT_ID}/secrets/{name}/versions/latest" ) # --- RAG retrieval tool --- RAG_CORPUS = os.environ.get("RAG_CORPUS", "") # set via Secret Manager or env rag_tool = None if RAG_CORPUS: from google.adk.tools import VertexAiRagRetrieval rag_tool = VertexAiRagRetrieval( name="retrieve_knowledge", description="Retrieve relevant documentation from the knowledge base.", rag_resources=[rag.RagResource(rag_corpus=RAG_CORPUS)], similarity_top_k=10, vector_distance_threshold=0.6, ) # --- Root agent --- root_agent = Agent( model="gemini-2.5-flash", # cost-optimized default name="oavauco_root", description="OSVauco enterprise agent for propane-will-491900-m5", instruction=( "You are OSVauco, a GCP knowledge and workflow agent. " "Use the retrieve_knowledge tool to answer questions from the knowledge base. " "Always prefer grounded, documented answers over speculation." ), tools=[rag_tool] if rag_tool else [], )